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:]+" does not match "aaaaa"
- "[a-z]" matches the string "a"
- "a+" matches "aaaaa"
- "a{3,20}" does not match "aaaaa"
- Switching to egrep, grep, extended or awk made no difference.
- Switching to ECMAScript resulted in an exception.