Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Regular Expression Backtracking Problem

807606Mar 21 2007 — edited Mar 22 2007
I have a complex regular expression along the lines of

[extremely_long_expression_with_lots_of_wildcards]abcdefg

It takes several minutes for the Java regex parser to determine that the string against which I'm matching the expression does not contain 'abcdefg'. It appears to be "backtracking" and trying to find some sort of match in the long expression, even though the complete expression cannot match due to the absence of 'abcdefg'.

Is there a way to make the parser look first for 'abcdefg', notice that it's not in the string, and fail immediately?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 19 2007
Added on Mar 21 2007
24 comments
799 views