Complex serach and replace in C++ string

Hi! Is it possible search and replace or delete a character in a piece of string delimited by 2 positions found by the method find() (find() return position (size_t) and not an iterator) using some function of boost? -- View this message in context: http://boost.2283326.n4.nabble.com/Complex-serach-and-replace-in-C-string-tp... Sent from the Boost - Users mailing list archive at Nabble.com.

Is it possible search and replace or delete a character in a piece of string delimited by 2 positions found by the method find() (find() return position (size_t) and not an iterator) using some function of boost?
I'm not sure what you mean by "delimited by 2 positions" (could you give an example?), but note that you can easily (and efficiently) convert the result of find() to an iterator like this: string::const_iterator it = s.begin() + s.find("something"); Regards, Nate

In detail: If I have a string: Hello World! I am out! '*here I am in*' out there '*and here still inside! *'Hello! Should I trim it outside the quote symbol: HelloWorld!Iamout!'*Here I am in*'outthere'*and here still inside! *'Hello! -- View this message in context: http://boost.2283326.n4.nabble.com/Complex-serach-and-replace-in-C-string-tp... Sent from the Boost - Users mailing list archive at Nabble.com.

Hi Claude,
Remember if you have access to a recent C++ compiler, you can use regular
expressions! If not, you can still use the Boost alternatives: Boost.Regex
or Boost.Xpressive.
I'm assuming that you know beforehand the number of "quoted sub-strings",
because otherwise, regular expressions are not so useful, and people often
recommend Boost.Spirit, which is too complex for this simple task.
About the trim operation you want to do in the outside parts, remember
Boost.StringAlgo has it for you. ;-)
Good luck,
Júlio.
2012/3/6 Claude
In detail: If I have a string:
Hello World! I am out! '*here I am in*' out there '*and here still inside! *'Hello!
Should I trim it outside the quote symbol:
HelloWorld!Iamout!'*Here I am in*'outthere'*and here still inside! *'Hello!
-- View this message in context: http://boost.2283326.n4.nabble.com/Complex-serach-and-replace-in-C-string-tp... Sent from the Boost - Users mailing list archive at Nabble.com. _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (3)
-
Claude
-
Júlio Hoffimann
-
Nathan Ridge