C++ Regex getting all match's on line -


when reading line line call function on each line looking function calls(names). use function match valid characters a-z 0-9 , _ '('. problem not understand c++ style regex , how through entire line possible matches?. regex simple , strait forward not work expected im learning c++ norm.

void readcallbacks(const std::string lines) {   std::string regxstring = "[a-z0-9]+\(";   regex regx(regxstring, std::regex_constants::icase);   smatch result;    if(regex_search(lines.begin(), lines.end(), result, regx, std::regex_constants::match_not_bol))   {     cout << result.str() << "\n";   } } 

you need escape backslash or use raw string literal:

std::regex pattern("[a-z0-9]+\\(", std::regex_constants::icase); //                           ^^  std::regex pattern(r"([a-z0-9]+\()", std::regex_constants::icase); //                 ###^^^^^^^^^^^## 

also, character range doesn't contain desired underscore (_).


Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -