fork(1) download
  1. #include <regex>
  2. #include <string>
  3. #include <iostream>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. string generalCast = R"((\d+(?:\.\d+){3})_(\d+(?:\.\d+)+)_(\d+))";
  9. string input = "127.27.18.4_2.125.2.365.24.2_10";
  10. std::regex rx(generalCast);
  11. smatch m;
  12. if (std::regex_match(input, m, rx)) {
  13. std::cout << m[1].str() <<"\n";
  14. std::cout << m[2].str() <<"\n";
  15. std::cout << m[3].str() <<"\n";
  16. }
  17.  
  18. }
Success #stdin #stdout 0s 3496KB
stdin
Standard input is empty
stdout
127.27.18.4
2.125.2.365.24.2
10