Boost logo

Boost Users :

From: John Maddock (john_at_[hidden])
Date: 2004-11-10 06:50:24


> Using "regex_replace(string, pattern, replace_string, flags)" I got some
> unwished results. I can't find out what flag set I have to use, that the
> replacement string was taken, as it is.
> I think this short example should make my problem clear:
> Replace in a string all occurences of PATH through the actual windows
> directory:
> "Actual path: 'PATH'"
> with Path "D:\temp\rest"
> leads to the string: "Actual Path: 'D: emp
> est'"
> This show, that "\t" and "\r" was interpreted. For me that is an
> unexspected
> behaviour, because the replacement is just some string, not more. I
> understand
> that the pattern will be interpreted and controlled over the flags, but
> why the
> replacement string? Can somebody explain that behaviour and show me a way
> out?

You have to double up escapes, and also escape '$'s as well: see the format
string syntax for a guide, maybe I should add a "format_literal" option as
well though,

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