Boost logo

Boost Users :

From: Stuart Dootson (stuart.dootson_at_[hidden])
Date: 2004-12-03 09:25:56


On Fri, 3 Dec 2004 14:00:01 +0100, Leon Mergen <leon_at_[hidden]> wrote:
> Hello,
>
> I'm trying to use boost regex'es replace and add a trailing 0 after the \1 part. However, it seems to want to replace this with
> \10, which is not what I want.
>
> Anyone has any idea how to do this in a proper way ?
>
> Thanks in advance!
>
> Regards,
>
> Leon Mergen

If you use the 'format_all' flag, you can use something like

($1)0

as a format string. For example,

boost::regex_replace(std::string("Hello"),
boost::regex("([a-zA-Z]+)"), "[($1)0]",
boost::regex_constants::format_all);

yeilds the string "[Hello0]

HTH

Stuart Dootson


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