I'm trying to use the C++ regex library. I would expect "aaaaa" to match "[a-z]+", but that is not happening. The code below is exactly that which I am running. When run, it prints nothing. (I would expect it to print "Match!")
#include <regex>
#include <iostream>
int main(int argc, char **argv) {
std::regex r("[a-z]+", std::regex_constants::basic);
if ( std::regex_match("aaaaa", r)) {
std::cout << "Match!" << std::endl;
}
return 0;
}
This is my build command:
$ g++ a.cc -std=c++11
I'm very confused. What do I need to do to make repetitions play nice with bracket expressions?
Notes:
I've tried a few experiments:
- "[:lower:]+" no match
I'm tried [:lower:]. Same result as above. I've also tried "a+". That works fine. "a{3,20}" does not result in a match.
Aucun commentaire:
Enregistrer un commentaire