0 votes
in JavaScript by
What are modifiers in regular expression in Javascript?

1 Answer

0 votes
by

Modifiers can be used to perform case-insensitive and global searches. Let's list down some of the modifiers,

ModifierDescription
iPerform case-insensitive matching
gPerform a global match rather than stops at first match
mPerform multiline matching

Let's take an example of global modifier,

var text = "Learn JS one by one";
var pattern = /one/g;
var result = text.match(pattern); // one,one
...