This post originated from an RSS feed registered with .NET Buzz
by Peter van Ooijen.
Original Post: Use a regular expression to lock up the webserver
Feed Title: Peter's Gekko
Feed URL: /error.htm?aspxerrorpath=/blogs/peter.van.ooijen/rss.aspx
Feed Description: My weblog cotains tips tricks and opinions on ASP.NET, tablet PC's and tech in general.
I am a rookie when it comes to regular expressions but learned one thing which I want to share with you. With a regular expression you can do very sophisticated matching of string patterns. The content of a regullar expression is a science on itself. The .net framework makes evaluating the expression quite simple.
string Pat = MyRegularExpression;
RegexOptions options = new RegexOptions(); options |= RegexOptions.Singleline;
Regex r = new Regex(Pat, options); Match m = r.Match(MyStringToSearch);
if (m.Success)
The Match method of the RegEx class will do the actual matching. What the documentation does not tell you is that it can take virtually forever to execute this statement. We had a beautifull expression which worked very well on a test string. Skimming the contents of a 396 KB text file went different. Starting the match drove the aspnet worker process (w3wp on server 2003) to 100 % processor utilization (51% on a (hypertreaded) dual) which locked up the server. We killed the process after half an hour. Nobody can wait that long.
Browsing the net I found this post on MSDN which explained what was going on. Finally found a need for supercomputing@home.