fork(30) download
  1. #include <iostream>
  2. #include <regex>
  3. using namespace std;
  4.  
  5. int main() {
  6. std::string pattern("A|D");
  7. std::regex rx(pattern);
  8.  
  9. std::string s("ABCDEABCABD");
  10. std::ptrdiff_t number_of_matches = std::distance(
  11. std::sregex_iterator(s.begin(), s.end(), rx),
  12. std::sregex_iterator());
  13.  
  14. std::cout << number_of_matches << std::endl;
  15. return 0;
  16. }
Success #stdin #stdout 0s 3544KB
stdin
Standard input is empty
stdout
5