c++ - boost::regex 中的嵌套量词

标签 c++ regex boost

\d++ 是不支持所有格量​​词的编程语言中的有效正则表达式吗?它等同于 (\d+)+ 吗?

在Python中测试时,会报错sre_constants.error: multiple repeat。在C#中,会抛出运行时异常:System.ArgumentException: parsing "\d++"- 嵌套量词 +。以及 boost::xpressive。
但是 \d++...+ 在 boost::regex 中被认为是有效的。

wchar_t* s = L"abc123" ;
wregex e(L"\\d+++", boost::regex::normal) ;
wcmatch m ;

if(regex_search(s, m, e)){
    wcout <<  m[0] << endl ;
}

输出是123

最佳答案

上面的代码为我抛出一个 boost::bad_expression 实例,其中包含“无效的前置正则表达式”。 它是用gcc 3.4.6和boost 1_32编译的redhat linux系统。

关于c++ - boost::regex 中的嵌套量词,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3593838/

相关文章:

javascript - JS : Trying to test for a very specific pattern

c++ - boost::locale::date_time:如何从 Boost C++ 中的 date_time 对象获取数据?

C++/Boost MPL : structure code likewise Haskell's let, 其中,

c++ - 从 C++ 中的两个类继承并插入到列表中

c++ - Qt : Drawing Blended Transparent Lines/Curves/Paths

regex - 将正则表达式传递给 perl 子程序

javascript - Javascript 中两个不同字符串正则表达式之间的所有文本

r - 无法让 RQuantLib 在 osx 10.9.4 下与brew安装的 quantlib 一起使用

java - 如何将opencv代码转换为javacv代码

c++ - Boost directory_iterator 导致崩溃