I am attempting to use the regex_search
function in C++11 and my code is not finding the string as I would expect.
std::string regexString = "(?<=settings1)(.*)(?=;)";
std::regex rgx(regexString);
std::smatch match;
std::string settingValue;
if (std::regex_search("setting1=hellowSettingsWorld;", match, rgx)){
// match fond
settingValue = match[1];
cout << "string found " << settingValue << endl;
}else{
cout << "string not found "
}
I tested this regex out on regex101 and it tells me it should find the string "=hellowSettingsWorld"
https://regex101.com/r/nU7qK5/1
however the std::regex_search()
always returns false?
not sure if i am using the regex_search
function incorrectly or if there is something wrong with my regular expression?