JavaScript RegExp ?!Quantifier

RegExp 对象参考手册JavaScript RegExp Object

Definition and Usage

The ?!nThe quantifier matches that is not immediately followed by the specified stringnany string.

Syntax

new RegExp("regexp(?!n)")

or

/regexp(?!n)/


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the ?! quantifier.


Example

Example

Perform a global search for "is" that is not immediately followed by "all":

var str="Is this all there is";
var patt1=/is(?! all)/gi;

Belowmarkedtext shows the position where the expression obtained a match:

Is this all there is

Try it Yourself »


RegExp 对象参考手册JavaScript RegExp Object Other Extensions