|
Boost Users : |
From: Andrew Holden (aholden_at_[hidden])
Date: 2007-11-14 14:26:34
Peter Klotz wrote:
> The program below gives different output in Boost 1.32.0 compared to
> 1.33.1 and 1.34.1.
>
> In my opinion "R_Test" would be the correct result and therefore Boost
> 1.33.1 and 1.34.1 would be wrong.
>
> Can anyone clarify this issue?
>
> Best regards, Peter.
>
> #include <iostream>
> #include <boost/regex.hpp>
>
> int main()
> {
> // Boost 1.32.0: "R_Test"
> // Boost 1.33.1 and 1.34.1: "R_TestR_"
> std::cout <<
> boost::regex_replace(std::string("Test"),boost::regex("(.*)"),
> "R_$1") << std::endl; return 0; }
I would expect the behavior in Boost 1.33+. The regex first matches the
full string "Test", then it matches the empty string at the end.
Try changing the expression to "(.+)" to match 1 or more characters, or
"^(.*)" to match only the text at the beginning of the string.
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