đź“ť Edit page
âž• Add page
Modifiers
The notes here are for JavaScript but there will be equivalents in other languages.
Multiline
m modifier for multiline searches.
Do a multiline search for “is” at the beginning of each line in a string:
const str = "\nIs th\nis it?";
const patt1 = /^is/m;
The m modifier treat beginning (
^
) and end ($
) characters to match the beginning or end of each line of a string (delimited by\n
or\r
), rather than just the beginning or end of the string.
Global
const str = "Is this all there is?";
const patt1 = /is/g;
The
g
modifier is used to perform a global match (find all matches rather than stopping after the first match).
Insensitive
Do a case-insensitive search for “w3schools” in a string:
var str = "Visit W3Schools";
var patt1 = /w3schools/i;