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
Post a Comment