Latest

recent

JavaScript RegExp [xyz] Modifier

Definition and Usage

When the [xyz] modifier is set the regular expression finds 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 the character span "a" to "h":

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:02 Rating: 5
Powered by Blogger.