fork(1) download
  1. #include <string>
  2. #include <iostream>
  3. #include <regex>
  4. using namespace std;
  5.  
  6. int main() {
  7. string str1="hello \"trimthis\" please";
  8. regex rgx("\"([^\"]*)\""); // will capture "trimthis"
  9. for(sregex_iterator i = sregex_iterator(str1.begin(), str1.end(), rgx);
  10. i != sregex_iterator();
  11. ++i)
  12. {
  13. smatch m = *i;
  14. cout << "Value: " << m[1].str() << endl;
  15. }
  16. return 0;
  17. }
  18.  
Success #stdin #stdout 0s 4520KB
stdin
Standard input is empty
stdout
Value: trimthis