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
{1,}for once or more times, you would be better using x+, x+? or x++. See here for information about quantifiers in java.