c++ - regex_search() return false for positive lookbehind and lookahead -


i attempting use regex_search function in c++11 , code not finding string 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 regex out on regex101 , tells me should find string "=hellowsettingsworld"

https://regex101.com/r/nu7qk5/1

however std::regex_search() returns false?

not sure if using regex_search function incorrectly or if there wrong regular expression?

c++ <regex> implements according ecmascript (a.k.a. javascript) regexp small extension support posix character classes. since ecmascript regexp doesn't support look-behind, c++ <regex> doesn't support syntax.

as casimir et hippolyte suggested, use boost library if want more fancy regex features.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -