Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++11 Regex Matching [duplicate]

Tags:

c++

regex

gcc

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?

like image 413
Matt Kline Avatar asked Feb 25 '13 02:02

Matt Kline


1 Answers

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.

like image 177
Chris Dodd Avatar answered Sep 29 '22 20:09

Chris Dodd