So my professor gave me a work with regex in c++.
So I tried to write my code in eclipse (I am using linux (ubuntu 12.04)).
so I took the code :
// regex_search example
#include <iostream>
#include <string>
#include <regex>
int main ()
{
std::string s ("this subject has a submarine as a subsequence");
std::smatch m;
std::regex e ("\\b(sub)([^ ]*)"); // matches words beginning by "sub"
std::cout << "Target sequence: " << s << std::endl;
std::cout << "Regular expression: /\\b(sub)([^ ]*)/" << std::endl;
std::cout << "The following matches and submatches were found:" << std::endl;
while (std::regex_search (s,m,e)) {
for (auto x:m) std::cout << x << " ";
std::cout << std::endl;
s = m.suffix().str();
}
return 0;
}
As you can see it is a simple code for working with regex.
so I try to build it and eclipse gives me an error:
Type 'smatch' could not be resolved
and also:
Type 'std::regex' could not be resolved
what is the problem ?
I tried to get add the flag -std=c++0x in the suitable location (properties->c/c++ build ->Miscellaneous)and nothing happen.
maybe I am doing it wrong ?
maybe I have to add a link to library like in pthread ?