I'm using C++ on XCode. I'd like to match non-alphabet characters using regex_match but seem to be having difficulty:
#include <iostream>
#include <regex>
using namespace std;
int main(int argc, const char * argv[])
{
cout << "BY-WORD: " << regex_match("BY-WORD", regex("[^a-zA-Z]")) << endl;
cout << "BYEWORD: " << regex_match("BYEWORD", regex("[^a-zA-Z]")) << endl;
return 0;
}
which returns:
BY-WORD: 0
BYEWORD: 0
I want "BY-WORD" to be matched (because of the hyphen), but regex_match returns a 0 for both tests.
I confoosed.