1bigbear Posted November 17, 2009 Share Posted November 17, 2009 I got some text, and in the text there are a couple of javascripts, <script language='JavaScript' type='text/javascript' src='http://site.com/gfsdgf.js'></script> <script language='JavaScript' type='text/javascript'></script> <noscript><a href=''></a></noscript> And <script language="JavaScript"> flowplayer('in_tvPlayer_0',{ durationColor: '',}); </script> How can I remove only this javascripts, and keep the rest of the text? Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted November 17, 2009 Share Posted November 17, 2009 try this echo preg_replace("#<script[^>]+>.*?</script>|<noscript>.*?</noscript>#s", '' , $str); $str is the string that contains the html Quote Link to comment Share on other sites More sharing options...
thebadbad Posted November 17, 2009 Share Posted November 17, 2009 Or shortened: $str = preg_replace('~<((?:no)?script)\b[^>]*>.*?</\1>~is', '', $str); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.