|
Boost Users : |
From: John Maddock (john_at_[hidden])
Date: 2006-07-28 05:02:52
llwaeva_at_[hidden] wrote:
> Hi there,
> I am using regex_replace to find_replace a pattern. The code is
> shown below
>
> string src = "xxx%R__xy\r\n%\r\nRyyyy%
> A__%%A\r\n%Rzzz%C%Appp_%C0123\r\n%Rooo"; re = "(%R)|(%A)|(%C)";
> format = "(?1#R)(?2#A)(?3#C)";
> cout << "SOURCE:" << endl << src << endl << endl;
> regex_replace( src.begin(), src.begin(), src.end(), re, format,
> format_all ); cout << "OUTPUT:" << endl << src << endl << endl;
OK I've just realise what you're doing, and in short DON'T DO THAT!!!!
regex_replace does not do inplace search and replace, YOU ABSOLUTELY CANNOT
OVERWRITE A STRING YOU'RE STILL READING FROM!
Use:
src = regex_replace(src, re, format, format_all);
instead.
John.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net