from what i researched, the expression "[:alpha:]" will be matched for any alphabetic character, but the expression only match for lowercase character and not uppercase character. I not sure what's wrong with it.
std::regex e ("[:alpha:]");
if(std::regex_match("A",e))
std::cout<<"hi";
else
std::cout<<"no";
Change this:
std::regex e ("[:alpha:]");
to:
std::regex e ("[[:alpha:]]");
As Adrian stated: Please note that the brackets in the class names are additional to those opening and closing the class definition. For example: [[:alpha:]]
is a character class that matches any alphabetic character. Read more in the ref.
You have to use [[:alpha:]]
see online example
#include <iostream>
#include <string>
#include <regex>
using namespace std;
int main() {
std::regex e ("[[:alpha:]]");
if(std::regex_match("A",e))
std::cout<<"hi";
else
std::cout<<"no";
return 0;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With