Opened 21 years ago

Closed 19 years ago

#946 closed Bugs (Fixed)

regexp enters in a infinite loop

Reported by: nobody Owned by: John Maddock
Milestone: Component: regex
Version: None Severity:
Keywords: Cc:

Description

In the code below the regular expression fain to 
pass the line regex.Search(). So the line with if 
instruction will never be reached.

const char* szExpr = "([A-Z][a-z\\, ]+)+";
const char* szData =  "continent mostly south of the 
Antarctic Circle etc";
boost::RegEx regex(szExpr, true);
bool bFound = regex.Search(szData);
if(bFound)
    cout << regex[0].c_str() << endl;



my email address is balcanuc@yahoo.com

Change History (3)

comment:1 by nobody, 21 years ago

Logged In: NO 

OK the problem here is that by making the expression case 
insensitive [A-Z] and [a-z] are the same thing.  In effect 
you have created an expression that is more or less :

(.+)+

and that is one that's well known to become pathological 
(if I've got this right there are in effect n! ways to 
locate a match using an expression like this against an n-
character string).

I'm going to leave this issue open though, as there should 
be a way to detect and abort from pathological behaviour in 
the regex engine.

regards,

John Maddock

comment:2 by John Maddock, 19 years ago

Logged In: YES 
user_id=14804

The current code will detect "infinite loops" and throw and 
exception to break out of them.

John Maddock

comment:3 by John Maddock, 19 years ago

Status: assignedclosed
Note: See TracTickets for help on using tickets.