JavaScript RegExp [abc]Expression

RegExp 对象参考手册JavaScript RegExp Object

Definition and Usage

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

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

Syntax

new RegExp("[abc]")

Or a simpler way:

/[abc]/


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the [abc] expression


Example

Example

Perform a global search for the character range [a-h] in a string:

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

BelowmarkedThe text shows where the expression gets a match:

Is this all there is?

Try it Yourself »


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