c++ - PCRE does not match -


i suppose it's stupid, not match, , have no idea why. compiles , everything, doesn't match. i've used re(".*") doesn't work well. system os x (installed pcre using brew).

std::string s; if (pcrecpp::re("h.*o").fullmatch("hello", &s)) {     std::cout << "successful match " << s << std::endl; } 

you trying extract 1 subpattern (in &s), have not included parentheses capture subpattern. try (untested, note parentheses).

std::string s; if (pcrecpp::re("(h.*o)").fullmatch("hello", &s)) {     std::cout << "successful match " << s << std::endl; } 

the documentation @ http://www.pcre.org/original/doc/html/pcrecpp.html has similar example, stating:

example: fails because there aren't enough sub-patterns:
!pcrecpp::re("\w+:\d+").fullmatch("ruby:1234", &s);


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -