JavaScript RegExp ?! 量词

定义和用法
The ?!n 量词匹配其后没有紧接指定字符串 n 的任何字符串。
语法
new RegExp("regexp(?!n)")
或者
/regexp(?!n)/
或者
/regexp(?!n)/
浏览器支持
所有主要浏览器都支持 ?! 量词。
实例
实例
对其后没有紧跟 "all" 的 "is" 进行全局搜索:
var str="Is this all there is";
var patt1=/is(?! all)/gi;
var patt1=/is(?! all)/gi;
下面 被标记 的文本显示了表达式获得匹配的位置:
Is this all there is
尝试一下 »

点我分享笔记