Reputation: 37
I have a paragraph on which i am trying to apply a regular expression. Unfortunately its entering into an infinite loop. Could you please let me know what is wrong with this regex.
Regex,
(([A-Z]\w*[\s\.\u0026]*){1,}\s(\d{4})|(\d{4})\s([A-Z]\w*[\s\.\u0026]*){1,})\s(\(\d+\))\s(\d+)
Paragraph,
WHEREAS Dr. L. S. Meena, Scientist C Gr. IV(2) has been convicted on criminal charge under section 815.04(4)(A) Offence against Intellectual Property during his stay in USA under BOYSCAT Fellowship and has been awarded a sentence to serve 24 day(s) in the Orange County Jail with credit for 24 day(s) time served w.e.f. 22nd March, 2005 by the CIRCUIT COURT OF THE NINTH JUDICIAL CIRCUIT, IN AND FOR ORANGE COUNTY, FLORIDA, USA.
Also can you tell me is there any tool that could tell me if there are any loopholes in the regex written?
Thanks, Harsha
Upvotes: 0
Views: 585
Reputation: 20654
That looks like a 'pathological' regex, i.e. it suffers from catastrophic backtracking because of the repeated repeats, such as ([A-Z]\w*[\s\.\u0026]*){1,}
.
Catastrophic backtracking is explained here: http://www.regular-expressions.info/catastrophic.html
Upvotes: 1