[prev in list] [next in list] [prev in thread] [next in thread] 

List:       boost-users
Subject:    Re: [Boost-users] regex_replace to replace a number?
From:       "John Maddock" <john () johnmaddock ! co ! uk>
Date:       2004-02-25 11:29:42
Message-ID: 006c01c3fb99$1a90ef60$e7810252 () fuji
[Download RAW message or body]

> I am a newbie to regex.  Can anyone please help?  I am trying to replace
$number with a number 2 but instead it looks for argument number 12.  What
is the format or escape sequence format_string variable needs to be?
>
> regex e("(\\$number)");
>
> const char* format_string = "(?12)";
>
> regex_replace(out, file_stream.begin(), file_stream.end(), e,
format_string, match_default | format_all);

Put some parenthesis around the 2:

const char* format_string = "(?1(2))";

John.

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic