js 如何通过正则过滤jscss html回车、空格 代码STYLEa{font-size:15px}/STYLEscript function aa(){}
js 如何通过正则过滤js css html 回车、空格 代码
<STYLE>a{font-size:15px}</STYLE>
<script >function aa(){}</script>
<body>测试1
测试2</body>
我要是实现 测试1测试2 也就是把没用html、js css 回车、空格都去掉
正则 js
[解决办法]
str = str.replace(/<script>[.\n\r]*<\/script>
[解决办法]
<style>[.\n\r]*<\/style>/gi, '').replace(/<[^>].*?>/g,"");
[解决办法]
str.replace(/<(style
[解决办法]
script
[解决办法]
iframe)[^>]*?>[\s\S]+?<\/\1\s*>/gi,'').replace(/<[^>]+?>/g,'').replace(/\s+/g,'')
