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

ShowUsYour<Regex>

Irregular Expressions Regularly

Patterns which caused timeouts to occur

It's been 2 or 3 weeks since I added timeout protection to the RegexLib.com site. During that period I've averaged 1 or 2 timed out patterns per day. I thought that I'd post a small selection of some which have caused timeout exceptions.

The following 9 samples show the pattern and the input string which caused the failure; for the last 3 I've just shown "{LARGE BODY OF TEXT}" instead of the actual text which, in each case was a large amount of Html source.

Pattern:      ^[a-zA-Z0-9]+((.?|\-*)[a-zA-Z0-9]+)*$ 
Input string: 
asdf.host-name.asd-f.

 

Pattern 
^(([a-zA-Z\d!#$%&'*+-/=?^_`{|}~]+\x20*|"((?=[\x01-\x7f])[^"\\]|\\[\x01-\x7f])*"\x20*)*(?<angle><))?
((?!\.)(\.?[a-zA-Z\d!#$%&'*+-/=?^_`{|}~]+)+|"((?=[\x01-\x7f])[^"\\]|\\[\x01-\x7f])*")
@
(((?!-)[a-zA-Z\d\-]+(?<!-)\.)+[a-zA-Z]{2,}
|\[
(((?(?<!\[)\.)(25[0-5]|2[0-4]\d|[01]?\d?\d)){4}
|[a-zA-Z\d\-]*[a-zA-Z\d]:((?=[\x01-\x7f])[^\\\[\]]|\\[\x01-\x7f])+)
\])
(?(angle)>)$
Input string: 
www42af43ds.afsd.fds.ds

 

Pattern 
^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@(([0-9a-zA-Z])+([-\w]*[0-9a-zA-Z])*\.)+[a-zA-Z]{2,9})$
Input string: 
hello23423423423424n@aol.c

 

Pattern 
^((?:[a-zA-Z]:)|(?:\\{2}\w+)\$?)\\([^\\/:*?<>"| ](?:[^\\/:*?<>"|]*[^\\/:*?<>"| ])*\\)*((?:[^\\/:*?<>"|]*[^\\/:*?<>"| ])+\.(?:[^\\/:*?<>"|]*[^\\/:*?<>"| ]){2,15})?
Input string: 
C:\RECYCLER\S-1-5-21-878277593-965038143-782984527-1002

 

Pattern 
^\w{1}[a-zA-Z]+(([\'\,\.\- ][a-zA-Z ])?[a-zA-Z]*)*$
Input string: 
gjlglujhL'KJK'LKJL'KLJKL-JKHKJHGK

 

Pattern 
^[A-Za-z0-9](([_\.\-]?[a-zA-Z0-9]+)*)@([A-Za-z0-9]+)(([\.\-]?[a-zA-Z0-9]+)*)\.([A-Za-z]{2,})$
Input string: 
michael.sumeranoscranton.edu

 

Pattern 
(<table.*align=\"right\">)((\s*.*\s*)*?)(<table)((.*|\s*)*?)(</table>)
Input string: 
{LARGE BODY OF TEXT}

 

Pattern 
(<table.*align=\"right\">)((\s*.*\s*)*?)((\s*.*\s*)*?)(<table)((.*\s*)*?)(</table>)((\s*.*\s*)*?)(</table>)
Input string: 
{LARGE BODY OF TEXT}

 

Pattern 
(<table)((\s*.*\s*)*?).*(<FONT\sFACE=\"arial).*(Related\s Articles).+((\s*.*\s*)*?)(</table>)((\s*.*\s*)*?)(</table>) 
Input string: 
{LARGE BODY OF TEXT}

 

Sponsor
Published Thursday, August 19, 2004 12:18 AM by digory
Filed under:

Comments

 

digory said:

Thanks for pointing this out Darren. I've changed this pattern

^((?:[a-zA-Z]:)|(?:\\{2}\w+)\$?)\\([^\\/:*?<>"| ](?:[^\\/:*?<>"|]*[^\\/:*?<>"| ])*\\)*((?:[^\\/:*?<>"|]*[^\\/:*?<>"| ])+\.(?:[^\\/:*?<>"|]*[^\\/:*?<>"| ]){2,15})?

To

^((?:[a-zA-Z]:)|(?:\\{2}\w+)\$?)\\(?>(?>(?![\\/:*?<>"|])(?!\x20(?:\\|$))[\x20-\x7E])+\\)*((?:((?![\\/:*?<>"|])(?![ .]$)[\x20-\x7E])+)\.(?:((?![\\/:*?<>"|])(?![ .]$)[\x20-\x7E]){2,15}))?$

Which hopefully won't suffer the same problem.
August 20, 2004 3:29 AM
 

digory said:

No problems Michael. I'm thinking about adding a feature whereby the author of the pattern will receive a notification if their pattern is involved in a timeout.
August 20, 2004 8:18 AM
 

digory said:

cccvc
October 13, 2004 12:35 PM
 

digory said:

March 5, 2005 6:54 PM
Anonymous comments are disabled