Advertisement
Guest User

Untitled

a guest
Jun 30th, 2015
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. #include<iostream>
  2. #include<regex>
  3. #include<string>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. bool found;
  9. cmatch m;
  10. try
  11. {
  12. found = regex_search("<html>blah blah blah </html>",m,regex("<.*>.* </\1"));
  13. cout<< found<<endl<<m.str();
  14. }
  15. catch(exception & e)
  16. {
  17.  
  18. cout<<e.what();
  19. }
  20.  
  21. return 0;
  22.  
  23.  
  24. }
  25.  
  26. #include<iostream>
  27. #include<regex>
  28. #include<string>
  29. using namespace std;
  30.  
  31. int main()
  32. {
  33. bool found;
  34. cmatch m;
  35. try
  36. {
  37. found = regex_search("<html>blah blah blah </html>",m,regex("<(.*)>(.*)</\1>"));
  38. cout << "***whole match***n";
  39. cout << "found=" << found << endl;
  40. cout << m.str() << endl;
  41.  
  42. cout << "n*** parts ***" << endl;
  43. for (const auto& c : m) {
  44. cout << c << endl;
  45. }
  46.  
  47. }
  48. catch(exception & e)
  49. {
  50.  
  51. cout<<e.what() << endl;
  52. }
  53.  
  54. return 0;
  55.  
  56.  
  57. }
  58.  
  59. ***whole match***
  60. found=1
  61. <html>blah blah blah </html>
  62.  
  63. *** parts ***
  64. <html>blah blah blah </html>
  65. html
  66. blah blah blah
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement