Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<regex>
- #include<string>
- using namespace std;
- int main()
- {
- bool found;
- cmatch m;
- try
- {
- found = regex_search("<html>blah blah blah </html>",m,regex("<.*>.* </\1"));
- cout<< found<<endl<<m.str();
- }
- catch(exception & e)
- {
- cout<<e.what();
- }
- return 0;
- }
- #include<iostream>
- #include<regex>
- #include<string>
- using namespace std;
- int main()
- {
- bool found;
- cmatch m;
- try
- {
- found = regex_search("<html>blah blah blah </html>",m,regex("<(.*)>(.*)</\1>"));
- cout << "***whole match***n";
- cout << "found=" << found << endl;
- cout << m.str() << endl;
- cout << "n*** parts ***" << endl;
- for (const auto& c : m) {
- cout << c << endl;
- }
- }
- catch(exception & e)
- {
- cout<<e.what() << endl;
- }
- return 0;
- }
- ***whole match***
- found=1
- <html>blah blah blah </html>
- *** parts ***
- <html>blah blah blah </html>
- html
- blah blah blah
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement