js对正则回顾不支持的解决方法
现在版本的javascript不支持
(?<!exp),零宽度负回顾后发断言(不支持negativelookbehind)
(?<=exp)也叫零宽度正回顾后发断言(positivelookbehind不支持):
可用下面方法代替:
测试例子:
<script type="text/javascript" > h='<html id="asd">asdsa12</html>' //var reg= new RegExp('<\\w+>.*(?=<\/html>)','g') var tmp=h.match(/<(\w+)[^>]*>.*(?=<\/\1>)/g); alert(tmp) tmp=h.replace(/<(\w+)[^>]*>(.*)(<\/\1>)/g,"$2"); alert(tmp) </script>