根据 this reference ,我应该能够将单个数字与
std::regex e1 ("\\d");
但是,当我运行以下测试代码时,出现正则表达式异常。
#include <iostream>
#include <string>
#include <regex>
int main()
{
std::regex r("\\d");
std::string s("9");
if (std::regex_match(s, r)) { std::cout << "matched!" << std::endl; }
}
最佳答案
GCC 的 std::regex
支持尚未准备就绪。请参阅:Is gcc 4.8 or earlier buggy about regular expressions?
关于c++ - 使用 std::regex_match 匹配单个数字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20525528/