11

I'm attempting a fairly simple regex match in C++11 (using gcc 4.7.2), but I'm having a large amount of trouble. Attempting to construct a pattern using

std::regex unquoted(R"regex(\s*([^",]+)\s*)regex");

causes the constructor to throw a std::regex_error exception with the code std::regex_constants::error_escape. Several regex testers online have no problem with the same expression, and I've tried using different some of the different syntax options to no avail. Is there something fundamentally different about the C++ regex syntax that I'm not grasping?

Xeo
  • 129,499
  • 52
  • 291
  • 397
Matt Kline
  • 10,149
  • 7
  • 50
  • 87

1 Answers1

17

See gcc's stdc++11 implementation status page -- regexes are not supported as of gcc 4.8

Edit for posterity: As mentioned in the comments, the regex library is now in libstdc++ and should be in gcc 4.9 and on.

Matt Kline
  • 10,149
  • 7
  • 50
  • 87
Chris Dodd
  • 119,907
  • 13
  • 134
  • 226
  • I tried building it with clang and got the same result - is that because regardless of which compiler I use, my system is using the same C++ standard library? – Matt Kline Feb 25 '13 at 14:27
  • 3
    According to http://libcxx.llvm.org/, clang's own C++ standard library should support regex, but is only used by default on OSX. On other platforms, clang uses the 'native' C++ standard library by default. – Chris Dodd Feb 25 '13 at 18:33
  • `boost::regex` it is then. Thanks for the help! – Matt Kline Feb 25 '13 at 22:09