fork(2) download
  1. #include <iostream>
  2. #include <string>
  3. #include <regex>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.  
  9. std::string line("A50. hsih Y0 his ");
  10. std::smatch match;
  11. std::regex reg("[A][-+]?([0-9]*\\.[0-9]*|[0-9]+)");
  12.  
  13. if ( std::regex_search(line,match,reg) ){
  14. cout << match.str(0) << endl;
  15.  
  16. }else{
  17. cout << "nothing found" << endl;
  18. }
  19.  
  20. return 0;
  21. }
Success #stdin #stdout 0s 15336KB
stdin
Standard input is empty
stdout
A50.