fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <regex>
  4. using namespace std;
  5.  
  6. int main() {
  7. // your code goes here
  8. try
  9. {
  10. regex pattern("^([\\w]+) ([\\w]+) ([\\w]+)$");
  11. smatch m;
  12. string s = "ti re que";
  13. regex_match(s, m, pattern);
  14. cout << "Matches found: ";
  15. for (int i = 0; i < m.size(); i++)
  16. {
  17. cout << "[" << m[i] << "] ";
  18. }
  19. return 0;
  20. }
  21. catch (regex_error& e)
  22. {
  23. cout << e.what();
  24. return 1;
  25. }
  26. return 0;
  27. }
Success #stdin #stdout 0s 3364KB
stdin
Standard input is empty
stdout
Matches found: [ti re que] [ti] [re] [que]