2

I've not been able to get regex_replace from TR1 working.

#include <iostream>
#include <string>
#include <tr1/regex>

int main()
{
std::string str = "Hello world";
std::tr1::regex rx("world");
std::string replacement = "planet";
std::string str2 = std::tr1::regex_replace(str, rx, replacement);

std::cout << str2 << "\n";
}

str2 is an empty string.

5
  • Try this: <msdn.microsoft.com/en-us/library/bb982382.aspx>. See <msdn.microsoft.com/en-us/library/bb982727.aspx> for useful background information too. Commented Apr 14, 2009 at 14:09
  • you'll need to be more specific. What is the output of the code above? Does it compile? etc... Commented Apr 14, 2009 at 14:10
  • What compiler (manufacturer, version etc) are you using? Commented Apr 14, 2009 at 16:05
  • gcc version 4.3.2 (Ubuntu 4.3.2-1ubuntu12) Commented Apr 14, 2009 at 17:01
  • Never mind, I used boost instead. Commented Apr 14, 2009 at 18:22

0