fork(1) download
  1. #include <regex>
  2. #include <string>
  3. #include <iostream>
  4. using namespace std;
  5.  
  6. int main() {
  7. regex r(R"('[^\\']*(?:(?:''|\\.)[^\\']*)*')");
  8. string s(R"(arg1('value1') arg2('value '')2') arg3('user\'~!@#$%^&*_~!@#$%^&"*_-=+[{]}\|;:<.>?21**()**'))");
  9. for(std::sregex_iterator i = std::sregex_iterator(s.begin(), s.end(), r);
  10. i != std::sregex_iterator();
  11. ++i)
  12. {
  13. std::smatch m = *i;
  14. std::cout << m.str() << std::endl;
  15. }
  16. return 0;
  17. }
Success #stdin #stdout 0s 4536KB
stdin
Standard input is empty
stdout
'value1'
'value '')2'
'user\'~!@#$%^&*_~!@#$%^&"*_-=+[{]}\|;:<.>?21**()**'