Is \d++
a valid regular expression in programming languages that don't support possessive quantifier?Is it equivalent to (\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 ;
}
The output is 123
.