fork(1) download
  1. #include <iostream>
  2. #include <string>
  3. #include <regex>
  4. using namespace std;
  5.  
  6. int main() {
  7. std::regex re("\\w+");
  8. std::string subject("This is a test test");
  9.  
  10. std::ptrdiff_t match_count(std::distance(
  11. std::sregex_iterator(subject.begin(), subject.end(), re),
  12. std::sregex_iterator()));
  13.  
  14. std::cout << match_count << std::endl;
  15. return 0;
  16. }
Success #stdin #stdout 0s 15328KB
stdin
Standard input is empty
stdout
5