小编Moh*_*ian的帖子

使用正则表达式时c ++程序崩溃

到达正则表达式部分时编译崩溃后的代码:

我想检查收到的字符串中是否存在任何数字或不存在.

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

int main()
{
    int in, count, rate;
    char *w;
    cin >> count;

    for(in = 1; in < 5; in++) {
        rate = 0;
        cin >> w;
        cout << "Case #";
        cout << in;
        cout << ":";

        if (regex_match (std::string(w), regex("([0-9])")))
            ++rate;
        cout << rate;
        cout << endl;
    }
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

c++ regex gcc g++ mingw32

1
推荐指数
1
解决办法
709
查看次数

标签 统计

c++ ×1

g++ ×1

gcc ×1

mingw32 ×1

regex ×1