This question already has an answer here:
- C++11 Regex Matching 1 answer
I can't seem to get std::regex_search
to work. The simple code below won't return true no matter what string I input.
std::regex reg1("password");
std::string temp;
while (getline(std::cin, temp))
{
if (std::regex_search(temp, reg1))
std::cout<<"Match!"<<std::endl;
}
std::regex_match
will return true if I input "password". I have tried using gcc 4.8.4
and clang 3.6
. I'm assuming it's some silly issue, but I can't put my finger on it.
Aucun commentaire:
Enregistrer un commentaire