嵌套量词的boost ::正则表达式 [英] Nested quantifiers in boost::regex
问题描述
是 \\ D +
编程语言中有效的正前pression不支持占有欲量词?是不是等同于(\\ D +)+
?
Is \d++
a valid regular expression in programming languages that don't support possessive quantifier?Is it equivalent to (\d+)+
?
在Python中对其进行测试,误差 sre_constants.error:多重复
将raised.In C#中,它会抛出一个运行时异常: System.ArgumentException:解析\\ D + - 嵌套量词+
。至于以及升压:: X pressive结果
但 \\ D + ... +
被认为是有效的提振::正则表达式。
When testing it in Python,an error sre_constants.error: multiple repeat
will be raised.In C#,it will throw a runtime exception:System.ArgumentException: parsing "\d++" - Nested quantifier +
.As well as boost::xpressive.
But \d++...+
is considered valid in 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
。
推荐答案
以上code抛出的boost :: bad_ex pression与无效的preceding定期EX pression为实例我。
它在RedHat Linux系统用gcc编译3.4.6和提高1_32。
The above code throws an instance of boost::bad_expression with "Invalid preceding regular expression" for me. Its a redhat linux system compiled with gcc 3.4.6 and boost 1_32.
这篇关于嵌套量词的boost ::正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!