SoFunction
Updated on 2025-03-04

Regular expression i modifier (case insensitive)

Regular expression i modifier:

The i modifier is used to specify that the match of regular expressions is case-insensitive.

Syntax structure:

Constructor method:

new RegExp("regexp","i")

Direct Object Measurement Method:

/regexp/i

Browser support:

IE browser supports this metacharacter.
Firefox browser supports this metacharacter.
Google Chrome supports this metacharacter.

Example code:

var str="This is an antzone good"; 
var reg=/this/;
((reg));

The above code cannot match anything because it is case sensitive.

var str="This is an antzone good"; 
var reg=/this/i;
((reg))

The above code can be matched successfully because it is case-insensitive.