Users at My website Post Content in WYSIWYG, so they can also add harmful java script and Style sheet. so just to detect java script tag in my content I've written this regex->
$regex = "/\<script(.*?)?\>(.|\\n)*?\<\/script\>/i";
preg_match_all($regex, $html, $scripts);
print_r($scripts);
regex such that print_r($scripts) will give me:
array(
[0] => <script src="http://example.com"></script>
[1] => <script>// inline js$(document).ready( function() {});</script>
)
How can i do the same with stylesheet tag and remove javascript tag and stylesheet tag. above code only detect javascript how can i remove this tag
preg_replace("/<script(.*?)?\>(.|\\n)*?\<\/script\>/", "", $input_lines);andpreg_replace("/<style(.*?)?\>(.|\\n)*?\<\/style\>/", "", $input_lines);