I have a odd scenario where due to unpredicability of input, there was a good chance that a regex I needed to run would time out. Couple that with the fact that I needed to run hundreds of them at a time, I was in some trouble.
So, I found this thread:
http://weblogs.asp.net/justin_rogers/archive/2004/05/22/139337.aspx
So first, big ups to Justin rogers for posting.
In response I had this RegexWT class built in C# (Regex With Timeout). Which is essentially a wrapper around Regex where the fun methods all have an extra parameter specifying a millisecond time out.
Okay, so onto the code. First a disclaimer: 1) Use at your own risk. I haven't been through this code tooth and nail, so there may be some hidden baddies. 2) I know, already that there are some bugs that I haven't tracked down. Since putting into an engine I'm running, I've gotten a few exceptions after heavy abuse. However, I wanted to post it anyhow and will post updates as I make modifications. 3) If you see any baddies, please feel free to comment.
Here is the code, sorry for the mess as soon as I figure out how to get blogger to handle attachments I'll post the project files.