Re: What's wrong with this code?
| From: | James Holloway | Date: | Mon, 21 May 2001 13:38:31 +0000 |
| Subject: | Re: What's wrong with this code? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-53713@lists.php.net to get a copy of this message | ||
Hiya Plutarck,
The .*'s are greedy. Maybe you should do something like this (not tested):
$file = preg_replace("/(<script)([^>])*([^<])*(<\/script>)/i",
"<!-- RWW:
Scripting killed -->", $file);
That should replace something like:
<script language="Javascript">Some (code not<) </script>
with
<!-- RWW: Scripting killed -->
James.
""Plutarck"" <aemuli@spamclause.yahoo.com> wrote in message
news:9eb4nf$pdf$1@toye.p.sourceforge.net...
> I'm creating a filter to re-write webpages, and everything is going fine.
> I'm trying to strip out anything using the <SCRIPT> tag, and here's what I
> know works:
>
> $file = eregi_replace("<script.*>.*</script>", "<!-- RWW:
> Scripting
> killed -->", $file);
>
> But I use PCRE functions, so I don't want to use ereg in one place and
PCRE
> in another, so I tried:
>
> $file = preg_replace("#<script.*>.*</script>#i", "<!-- RWW:
> Scripting
> killed -->", $file);
>
> Thing is, that doesn't work. And I don't know why.
>
> I assume that the brackets are what is causing the trouble, but what do
> those brackets do in PCRE that requires they be escaped? But escaping them
> doesn't seem to work either...
>
> So, what's wrong with the second piece of code that isn't wrong in the
> first?
>
>
> Thanks in advance.
>
> Plutarck
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>