This regular expression:
<IMG\s([^''>]+|'[^']*'|'[^']*')+>
seems to process endlessly when given this text
<img src=http://www.blahblahblah.com/houses/Images/ single_and_multi/roof/feb09/01_img_trrnjks_vol2009.jpg' />
I would expect it to – not find a match (quickly) – because there is only one single quote in the text. I have had this happen in C# and also using the Expresso regex tool. If the text is a lot shorter it seems to work.
Other commenters have mentioned the complexity being the likely cause for the perfo problem. I’d add that if you’re trying to match something resembling an IMG tag, I think you want a regex more like this:
Of course, there are still valid HTML variations that this regex won’t catch. Like a closing
/(required in xhtml), or whitespace before the closing bracket. And it will pass some invalid cases, like unsupported attribute names.