Reputation: 2606
Does anyone have any idea why the following code would output "no match"?
boost::regex r(".*\\.");
std::string s("app.test");
if (boost::regex_match(s, r))
std::cout << "match" << std::endl;
else
std::cout << "no match" << std::endl;
Upvotes: 2
Views: 313
Reputation: 170308
I believe regex_match() matches against the entire string. Try regex_search() instead.
It would have worked with the following regex:
boost::regex r(".*\\..*");
and the regex_match() function. But again, regex_search() is what you're probably looking for.
Upvotes: 4