I'm on CentOS 7, using gcc version 4.8.5 20150623
, compiling with the -std=c++11
flag. My code is as such: (note that I am using namespace std;
)
bool compare_regex(const std::string & detection, std::string regstr)
{
bool found = false;
regex reg_matcher(regstr, std::regex_constants::extended);
smatch m;
if (regex_search(detection,m,reg_matcher)){
found = true;
}
else{
log_print("REGEX NOT MATCHED.");
}
return found;
}
This code does not return true
, even when I call it with detection = "The year 1864 was a year I tested my code on string"
and regstr=18
. I've tried more complicated regexes as well, but none of them work. What might be going wrong?