Re: Regular expression problem

by Reywob(at)aol.com

 Date:  Thu, 20 Sep 2001 12:29:39 EDT
 To:  hwg-languages(at)hwg.org
  todo: View Thread, Original
In a message dated 9/20/01 3:44:25 PM GMT Daylight Time, hmarq(at)yerpso.net 
writes:

> I don't really do much javascript, but I believe the regex problem is that
>  your first (.*) is being greedy and running to the last > in the file.  A 
>  place to start would be to replace the <script(.*)> with <script([^>]*)>

I've been doing more research, and have figured out what the problem is, but 
cannot find the cure:

The code is: <script ...> [some whitespace] <![CDATA[
The current regex is: /<script(.*)>\s*[^<!\[CDATA\[]/gi

The problem is the [^<!\[CDATA\[], which tells the regex not to match 
<![CDATA[.  Because it tells it "Do not match this code", even the snippet of 
code above will match, because it can stop just before the <![CDATA[.

I am unsure how this would have to be rewritten, but it has to be possible!

Thanks,
Peter.

HWG: hwg-languages mailing list archives, maintained by Webmasters @ IWA