fork download
  1. #include <iostream>
  2. #include<regex>
  3.  
  4. int main() {
  5. std::regex r("\\{[^}]*\\}");
  6. std::string str("{1}, {2} and {3}");
  7. auto words_begin =
  8. std::sregex_iterator(str.begin(), str.end(), r);
  9. auto words_end = std::sregex_iterator();
  10. for (std::sregex_iterator i = words_begin; i != words_end; ++i) {
  11. std::smatch m = *i;
  12. if (m.position() > 4) {
  13. std::cout << m.str() << std::endl;
  14. }
  15. }
  16. return 0;
  17. }
Success #stdin #stdout 0s 4472KB
stdin
Standard input is empty
stdout
{2}
{3}