|
Boost Users : |
Subject: Re: [Boost-users] [regexp] Replace a substring with a regexp
From: John Maddock (boost.regex_at_[hidden])
Date: 2011-03-18 05:53:50
> Search pattern: "\\u(\w{4})"
>
> It seems that we also have to escape the "\" in "\u". The working regex
> seems to be:
>
> "\\\\u(\w{4})"
>I'm surprised. The first backslash was already there to escape the
>second. Are there maybe two steps of backslash interpretation at work,
>one by the C++ compiler and one by Boost.Regex? In any case, I forgot
>to escape the backslash in "\w", you'd probably have to give that one
>the same treatment. And also the ones in "\&" and "\1" in the
>replacement pattern.
Yes, if you want to match a literal '\' then you need to use '\\\\' in the
regex - the compiler swallows one set of \'s so the regex engine then sees
'\\' which is what you want...
HTH, 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