Got more questions? Find advice on: ASP | SQL | XML | Windows
in Search
Welcome to RegexAdvice Sign in | Join | Help

ShowUsYour<Regex>

Irregular Expressions Regularly

Another interesting timeout pattern

I haven't had time to fully investigate the evilness of this pattern but it certainly looked interesting:

 

Pattern:

^(([^\\/:*?<>"|]*(?<![ ]))*~+)(\.[xsl]{3})$ Input String $d_ d}ddddddddddddFoo2.xsl.xsl
Sponsor
Published Monday, August 23, 2004 7:37 AM by digory
Filed under:

Comments

 

digory said:

That is just another greedy expression that will take a long time because it starts by matching the entire string, fails, backs off a character at a time, etc..., etc...

It would be obvious how it would maximize the string scanning. It'll never find the tilde character and being a required match item, that just won't happen. The use of the [xsl]{3} is the definite look of a very new user to regular expressions.

Changing the pattern to run RToL changes the paradigm because you quickly match the \.xsl and then fail to match the tilde character without incurring the greedy backtrack. If you try to non-greedy the match you run into the out-of-bounds exception.
August 25, 2004 12:40 AM
 

digory said:

True, thanks Justin... I did have this on my "stack of things to look at" but there's been a lot more pushing than popping lately :S

- Darren
August 25, 2004 9:25 PM
 

digory said:

October 26, 2004 10:31 AM
 

digory said:

Thanks, it was very interesting
March 5, 2005 6:54 PM
Anonymous comments are disabled