From: John Maddock (john_at_[hidden])
Date: 2008-04-10 11:29:58


Mihaly Zachar wrote:
> unfortunately this is a real problem...
> I'm interworking with an existing perl system and it provides me rexes
> what I sohuld use.
>
> We should have the same result for the same regexes.
>
> mitya_at_stamford:~$ perl -e '$in = "1111"; $in =~ s/(.*)/0$1/; print
> $in."\n"' 01111
> mitya_at_stamford:~$
>
> to set match_not_null is not good for me :(

OK so the Perl code doesn't set the /g modifier so it only replaces the
first match found: you can get the same behaviour in Boost.Regex by passing
the format_first_only flag as the last argument to regex_replace.

In other words the defaults are different: Boost.Regex defaults to "replace
all occurences" but you can choose to replace just the first one if you
want, and Perl is the other way around.

HTH, John.