Regex C++


SUBMITTED BY: Guest

DATE: May 3, 2013, 5:57 p.m.

FORMAT: C++

SIZE: 778 Bytes

HITS: 1144

  1. #include <iostream>
  2. #include <regex>
  3. #include <string>
  4. int main()
  5. {
  6. std::vector<std::string> str;
  7. std::vector<std::string> list;
  8. std::string tmp;
  9. do
  10. {
  11. std::cin >> tmp;
  12. list.push_back(tmp);
  13. } while (tmp != "END");
  14. do
  15. {
  16. std::cin >> tmp;
  17. str.push_back(tmp);
  18. } while (tmp != "END");
  19. for(auto& it : list)
  20. {
  21. std::cout << "Regex: " << it << std::endl;
  22. for(int i = 0; i < str.size(); ++i)
  23. {
  24. std::regex pattern(it, std::regex_constants::basic);
  25. std::cout << std::regex_match(str[i], pattern) << std::endl;
  26. }
  27. }
  28. return 0;
  29. }

comments powered by Disqus