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
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.