31_regex.cpp 271 B

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