«

C++ 使用regex正则表达式

benojan • 2024-03-07 21:38 • 135 次点击 • c/c++


案例

#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");
}

正则表达式 regex