std::regexが動かない?
いやそんなはずは。。
int main(void) { regex re("a+b"); string s = "aab"; smatch result; if(regex_search(s, result, re)){ cout << "YES" << endl; } else cout << "NO" << endl; return 0; }
が"NO"だったり、
int main(void) { regex re("[0-9]"); string s; cin >> s; if(regex_match(s, re)){ cout << "YES" << endl; } else cout << "NO" << endl; return 0; }
がre("[0-9]");のところで落ちたり
(
terminate called after throwing an instance of 'std::regex_error'
what(): regex_error
Aborted
)して困ってる。。
int main(void) { regex re("a+b"); string s = "aab"; smatch result; if(regex_match(s, re)){ cout << "YES" << endl; } else cout << "NO" << endl; return 0; }
は期待通り"YES"