Why does inputting "integral123" result in the last character of the first group being displayed, while the second group displays the first number?
1 2 3 4 5 6 7 8 9 10
|
regex expr("([[:alpha:]])([[:digit:]])");
smatch sm;
bool matched{};
for(string str{}; cin >> str; ) {
cout << ( (matched = regex_search(str, sm, expr)) ? "Match!" : "No match!" ) << "\n";
if(matched)
cout << "User: " << sm[1] << "\t" "Number: " << sm[2] << "\n\n";
else
cout << "\n";
}
|
integral123
User: l Number: 1
|
Last edited on