Latest

recent

JavaScript RegExp [^xyz] Modifier

Definition and Usage

When the [^xyz] modifier is set the regular expression finds characters that is not the specific characters or span of characters.
The characters inside the brackets can be any characters or span of characters.

Syntax

new RegExp("[^xyz]")
OR
/[^xyz]/


Example

In the following code we will do a global search for characters that not in the "a" to "h" span:

var str = "Is this all there is?";
var patt1 = new RegExp("[^a-h]","g");

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

Is this all there is?
JavaScript RegExp [^xyz] Modifier Reviewed by 1000sourcecodes on 22:01 Rating: 5
Powered by Blogger.