Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <regex>
- using namespace std;
- int main() {
- regex r(R"/(\d{2}\.\d{2}\.(\d{4}|\d{2}))/");
- string s = "20.10.219 Ваша заявка с номером #48278401010101010101 оформлена"s;
- smatch match;
- regex_search(s, match, r);
- cout << "match.str() "sv << match.str() << endl; // match.str() 20.10.21
- cout << "match[0].str() "sv << match[0].str() << endl; // match[0].str() 20.10.21
- cout << "match[1].str() "sv << match[1].str() << endl; // match[1].str() 21 <----------вопрос, почему именно 21?
- }
- ---
- // почему по шаблону |\d{2} нашлась цифра 21 -- то есть последняя пара цифр, а не первая пара цифр (20) например?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement