fork download
  1. #include <iostream>
  2. #include <regex>
  3. using namespace std;
  4.  
  5. int main() {
  6. std::regex regex(R"(\d+)");
  7. std::string nums("123, 451, 31-321");
  8. std::cout << std::regex_replace(nums, regex, "$&.0");
  9. return 0;
  10. }
Success #stdin #stdout 0s 16168KB
stdin
Standard input is empty
stdout
123.0, 451.0, 31.0-321.0