html - Regex To Remove Script And Style Tags + Content Javascript -
i've scenario have finish web pages having javascript, css , html. need remove script , style tags plus contents completely. have achieved in php using next regex:
$str = preg_replace('#<script(.*?)>(.*?)</script>#is', '', $html); preg_replace('#<style(.*?)>(.*?)</style>#is', '', $str);
but can't done in javascript. want have equivalent of
<script(.*?)>(.*?)</script> //in javascript
i want replace occurrences within html. have stripped out others html tags this
puretext.replace(/<(?:.|\n)*?>/gm, ''); //just reference
i want have equivalent of <script(.*?)>(.*?)</script> //in javascript
/<script([\s\s]*?)>([\s\s]*?)<\/script>/ig
use [\s\s]*?
instead of .*?
in regex because javascript won't back upwards s
modifier (dotall modifier). [\s\s]*?
match space or non-space character 0 or more times non-greedily.
javascript html regex
No comments:
Post a Comment