Nov 11, 2012 at 7:29pm UTC
I compiled this program using g++4.7 -std=c++11. It compiles but won't run. Can you give me help to get this working?
#include <iostream>
#include <regex>
#include <string>
int main()
{
std::string pattern("[^c]ei");
pattern = "[[:alpha:]]*" + pattern + "[[:alpha:]]*";
std::regex r(pattern);
std::smatch results;
std::string test_str = "receipt freind theif receive";
if(std::regex_search(test_str, results, r))
std::cout << results.str() << std::endl;
return 0;
}
-----------
When I run the program I get:
terminate called after throwing an instance of 'std::regex_error'
what(): regex_error
Abort trap (core dumped)
----------------
Nov 11, 2012 at 7:37pm UTC
Last edited on Nov 11, 2012 at 7:38pm UTC
Nov 11, 2012 at 9:02pm UTC
Works with clang++ (prints "freind"), but to use regex with gcc, you're going to need boost.