With regular expressions, it tends to much, much harder to say "do this
when a condition is false" than "do this when a condition is true".

One option that would at least fix the problem with the scripts (though
not the textareas or the PRE blocks) would be to replace [[:space:]]
with a class of space and tab.  This wouldn't remove line breaks.

Peter's suggestion of searching through some regex libraries is a good
one.  You may find something you could modify.

To get a better grip on the problem, can I ask why you're removing
whitespace?  Is this just to reduce page size?  Or is there a reason
I've overlooked?

--Ben Doom

Ryan Edgar wrote:

> I've written a simple Regex to remove all the whitespace from my templates:
>
> <CFSET PageSource = REReplace(PageScource, "[[:space:]]{2,}", " ", "ALL")>
>
> The problem I'm having is if there is _javascript_ on a page and there are
> inline comments, the _javascript_ won't work.
>
> alert('Hello'); // 1st line comment
> alert('Is anyone there?'); // 2nd line comment
>
> becomes:
>
> alert('Hello'); // 1st line comment alert('Is anyone there?'); // 2nd line
> comment
>
> Is there any way I can tell the Regex to ignore
> (<script([[:print:]])*>.*</script>) ?
> The same problem also exists with TEXTAREA and PRE where I want to keep text
> formatting in place.
>
> I've looked through the archives high and low but haven't been able to find
> anything, so any help at all would be greatly appreciated.
>
> TIA,
>
> Ryan Edgar
>
> Developer
> nga.net Pty Ltd.
>
> Level 2, 17 Raglan St
> South Melbourne 3205
>
> t. +61 (0)3 9694 5415
> f. +61 (0)3 9686 4611
>
> Searching for the best-fit e-recruitment software?
> http://www.nga.net.au
>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to