Pro.Luv Posted March 16, 2009 Share Posted March 16, 2009 Hi, Im still getting used to regex and I need some help could someone show me how to match javascript like : <script type="text/javascript"> function one(){ code.... } </script> how can I match this in html code ? I'm reading a file into a string I want to then find if theres javascript in the code and remove it ? Im using this to read the file: $html = file_get_contents("test.html"); Please help ! Quote Link to comment Share on other sites More sharing options...
premiso Posted March 16, 2009 Share Posted March 16, 2009 <?php $string = "test <script > function () { } </script> other text text of more. <script type=\"text/javascript\"> var test=1; function test() { }test </script> more text ok"; echo preg_replace('~<script(.+?)</script>~si', " ", $string); ?> 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.