Latest web development tutorials

RegExp [abc] expression

RegExp Object Reference JavaScript RegExp Object

Definition and Usage

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

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

grammar

new RegExp("[abc]")

或者更简单方式:

/[abc]/


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support [abc] expression


Examples

Examples

In a string of characters in the range [ah] 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