fork download
  1. #include <functional>
  2. #include <iostream>
  3. #include <regex>
  4. #include <string>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10. string const input = "The quick brown fox.";
  11. std::regex const words("[^\\s]+");
  12.  
  13. auto f = std::mem_fn(&std::smatch::str);
  14. std::sregex_iterator i = std::sregex_iterator(input.begin(), input.end(), words);
  15. std::smatch m = *i;
  16.  
  17. string first_word = f(m, 0);
  18.  
  19. return 0;
  20. }
Success #stdin #stdout 0s 3548KB
stdin
Standard input is empty
stdout
Standard output is empty