kehers
11-24-2006, 04:02 PM
Im trying to run a preg_replace for replacing some things in the contents of a retrieved webpage. For example, im using the snip below to strip out all javascripts within the content
preg_replace("/<script[^>]*?>.*</script*>/is", "", $content);
The problem with dat however is that, if there happens to be more than 2 script tags within the content, e.g,
<script>
some js codes
</script>
some content here, this should be omited
<script>
another js codes
</script>
the match matches from the begining script to the end script, swallowing allong "some content here". The idea is to simply replace contents within each individual script tags.
I tried using this but didnt work either...
preg_replace("/<script[^>]*?>[^(<\/script>)]*</script*>/is", "", $content);
any ideas?
preg_replace("/<script[^>]*?>.*</script*>/is", "", $content);
The problem with dat however is that, if there happens to be more than 2 script tags within the content, e.g,
<script>
some js codes
</script>
some content here, this should be omited
<script>
another js codes
</script>
the match matches from the begining script to the end script, swallowing allong "some content here". The idea is to simply replace contents within each individual script tags.
I tried using this but didnt work either...
preg_replace("/<script[^>]*?>[^(<\/script>)]*</script*>/is", "", $content);
any ideas?