String.scan hangs in some cases?

Parsing HTML with regular expressions is the work of the Devil.

Regards,

Dan

This communication is the property of Qwest and may contain confidential or
privileged information. Unauthorized use of this communication is strictly
prohibited and may be unlawful. If you have received this communication
in error, please immediately notify the sender by reply e-mail and destroy
all copies of the communication and any attachments.

···

-----Original Message-----
From: list-bounce@example.com
[mailto:list-bounce@example.com] On Behalf Of Wes Gamble
Sent: Wednesday, May 24, 2006 9:11 AM
To: ruby-talk ML
Subject: Re: String.scan hangs in some cases?

Just for kicks, here was the original regex - attempting to match
against a string containing an entire HTML page OR a style sheet.

/(?=<style)*?background.*?(?=-image)*?:.*?url\((.*?)\).*?(?=<\
/style>)*?/

I was attempting to make the <style and </style> parts optional.

As it turns out, there are so many different ways that a style can be
specified in a HTML page, that I just went with the much simpler:

/background.*?:.*?url\((.*?)\)/i

Wes