Latest web development tutorials

RegExp [^ abc] expression

RegExp Object Reference JavaScript RegExp Object

Definition and Usage

[^ Abc] expression is used to find any character not between the brackets.

Characters in square brackets can be any character or character range.

grammar

new RegExp("[^xyz]")

或者更简单方式:

/[^xyz]/


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support [^ abc] expression


Examples

Examples

Character is not in the character range [ah] within the global search:

var str="Is this all there is?";
var patt1=/[^a-h]/g;

The marked text below shows where the expression gets a match:

Is t h is a ll t he r e is?

try it"


RegExp Object Reference JavaScript RegExp Object