JavaScript RegExp iModifier

RegExp 对象参考手册JavaScript RegExp Object

Definition and Usage

The i modifier is used to perform case-insensitive matching.

Syntax

new RegExp("regexp","i")

Or a simpler way:

/regexp/i


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the i modifier.


Example

Example

Perform a case-insensitive search for "example" in the string:

var str="Visit example";
var patt1=/example/i;

Belowmarkedtext shows the position where the expression obtained a match:

Visit example

Try it yourself »


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