Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

RegExp [^abc] expression

JavaScript RegExp [^abc] expression

RegExp Object Reference JavaScript RegExp Object


Definition and Usage

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

The characters inside the brackets can be any character or a character range.

Syntax

new RegExp("[^xyz]")

Or a simpler way:

/[^xyz]/


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the [^abc] expression


Example

Example

Perform a global search for characters not in the range [a-h]:

var str="Is this all there is?";

var patt1=/[^a-h]/g;

The text marked below shows where the expression found matches:

Is t

h

is

a

ll t

he

r

e

is?

Try it »


RegExp Object Reference JavaScript RegExp Object