Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

It's there max groups limit in std::regex of C++?

Tags:

c++

regex

c++11

here is the code:

It's find when there are 31 groups:

try
{
    regex re("(0)(1)(2)(3)(4)(5)(6)(7)(8)(9)(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)(l)(m)(n)(o)(p)(q)(r)(s)(t)(u)", tr1::regex::icase);
}
catch (regex_error e)
{
    std::cout << e.what();
}

However, I try to add one more group (total 32 groups), oops:

try
{
    regex re("(0)(1)(2)(3)(4)(5)(6)(7)(8)(9)(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)(l)(m)(n)(o)(p)(q)(r)(s)(t)(u)(v)", tr1::regex::icase);
}
catch (regex_error e)
{
    std::cout << e.what();
}

a regex_error exception is caught and print

regular expression error

I use VisualStudio 2010 on Windows 7

It seems there is max limit of groups. How can I break the limit?

like image 618
Celebi Avatar asked Jan 07 '13 08:01

Celebi


1 Answers

Im not sure about the windows version but the gcc version only has partial support

http://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html#status.iso.2011

Its section 28 your looking at. Other languages seem to be able to match more groups

maybe try a differnt engine ?

http://en.wikipedia.org/wiki/Comparison_of_regular_expression_engines

like image 97
exussum Avatar answered Oct 04 '22 18:10

exussum