一、C++标准库<regex.h>
regex_replace函数一共包含三个参数:
参数一:需要被搜索替换的元字符串
参数二:正则表达式元素
参数三:被替换后的字符串。
#include <iostream>
#include <string>
#include <regex>
using namespace std;
int main() {
string str = "Mely Lenient Is A Bad Programmer!";
regex pattern("Bad");
cout << regex_replace(str, pattern, "Good") << endl;
return 0;
}