Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <regex>
- using namespace std;
- int main()
- {
- //Вводим строку
- string str;
- cout << "String> ";
- getline(cin, str);
- //Регулярка для поиска вхождений строки
- regex const exp("ABBA");
- //Можно ещё вот так бахнуть: auto const expression = (regex)"ABBA";
- //Ищем вхождения строки
- size_t result = distance(sregex_iterator(str.begin(), str.end(), exp),
- sregex_iterator());
- //Выводим результат
- cout << "Result: " << result << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement