首页 / c/c++ C++ 使用regex正则表达式

C++ 使用regex正则表达式

原创 分类: c/c++ 2024-3-7 21:38 阅读量:265
案例 #include iostream #include regex using namespace std; int main() { string str{ ang1\tm1-n1-ng1 ang1 }; regex e{ (...

案例

#include <iostream>
#include <regex>
using namespace std;

int main()
{
    string str{ "ang1\tm1-n1-ng1 ang1" };

    regex e{ "(^|[ \\-\\s])([mn])(g*)1" };

    cout << regex_replace(str, e, "$1$2$3");
}
收藏