1
0

24_regexcpp11.cpp 240 B

1234567891011121314
  1. #include <iostream>
  2. #include <regex>
  3. #include <string>
  4. using namespace std;
  5. int main()
  6. {
  7. string s = "Hello, world!";
  8. regex expr("(\\w+),\\s(\\w+)!");
  9. string fmt("$1, C++11!");
  10. cout << regex_replace(s, expr, fmt) << endl;
  11. return 0;
  12. }