gcc, of course, does not support the tr1 / C ++ 11 regular expression, but to give a more general answer, the default boost.regex value is perl 5 , according to its documentation, while C ++ defaults to ECMAScript extended several language elements of POSIX BRE.
In particular, boost.regex supports the extension extensions listed here . but you do not use them.
Now I was curious and ran the test through two more compilers:
Exiting clang:
~ $ clang++ -o test test.cc -std=c++11 -I/usr/include/c++/v1 -lc++ -lboost_regex ~ $ ./test Input : [FOO.*] Pattern : [FOO\.\*.*?] std::regex_match: true std::regex_search: true boost::regex_match: true boost::regex_search: true Input : [FOO.*.*.*.*] Pattern : [FOO\.\*.*?] std::regex_match: false std::regex_search: true boost::regex_match: true boost::regex_search: true
Exit Visual Studio 2012 (no promotion)
Input : [FOO.*] Pattern : [FOO\.\*.*?] std::regex_match: true std::regex_search: true Input : [FOO.*.*.*.*] Pattern : [FOO\.\*.*?] std::regex_match: true std::regex_search: true
Acquainted with the clang divergence, in the second test he compared the pattern [FOO\.\*.*?] With [FOO.*] And left [.*.*.*] Unsurpassed, which quickly reduces to comparing [S*?] By differently from boost / visual studio .. which, I think, is also a mistake.
source share