作者: 文章来源:
本文原地址:https://www.mimiwuqi.com/webqianduan/197070.html
目录文章目录[^abc] 表达式用于查找任何不在方括号之间的字符。
方括号内的字符可以是任何字符或字符范围。
new RegExp("[^xyz]")
或者更简单方式:
/[^xyz]/
所有主要浏览器都支持 [^abc] 表达式
对不在字符范围 [a-h] 内的字符进行全局搜索:
<script> var str="Is this all there is?"; var patt1=/[^a-h]/g; document.write(str.match(patt1)); </script>
下面被标记的文本显示了表达式获得匹配的位置:
Is this all there is?
程序运行结果:
I,s, ,t,i,s, ,l,l, ,t,r, ,i,s,?
更多 建站教程 请访问 https://www.mimiwuqi.com/webqianduan/