Re: preg_replace to delete all js code in string help needed
| From: | Curt Zirzow | Date: | Sun, 09 May 2004 14:00:38 +0000 |
| Subject: | Re: preg_replace to delete all js code in string help needed | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-185740@lists.php.net to get a copy of this message | ||
* Thus wrote Dave Carrera (dave@ephgroup.com):
> $text2 =
> preg_replace("/<script[^>]+>.*?<\/script>/is","",$text2);
>
> Leaves output with "language="javascript" blah blah
I tested that and it strips the script tags with "language" too. I
do know that it will not strip script tags that have no attributes:
<script> var yada;... </script>
This will fix that though:
/<script[^>]*?>.*?<\/script>/is
or
!<script[^>]*>.*</script>!/isU
Curt
--
"I used to think I was indecisive, but now I'm not so sure."