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 ! Link to comment https://forums.phpfreaks.com/topic/149644-preg_match-javascript/ 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); ?> Link to comment https://forums.phpfreaks.com/topic/149644-preg_match-javascript/#findComment-785870 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.