THE REGEXP TYPE
ECMAScript supports regular expressions through the RegExp type. Regular expressions are easy to create using syntax similar to Perl, as shown here:
let expression = /pattern/flags;
The pattern part of the expression can be any simple or complicated regular expression, including character classes, quantifiers, grouping, lookaheads, and backreferences. Each expression can have zero or more flags indicating how the expression should behave. Three supported flags represent matching modes, as follows:
g
—Indicates global mode, meaning the pattern will be applied to all of the string instead of stopping after the first match is found.i
—Indicates case-insensitive mode, meaning the case of the pattern and the string are ignored when determining matches.m
—Indicates multiline mode, meaning the pattern will continue looking for matches after reaching the end of one line of text.- y—Indicates sticky mode, meaning the pattern will only look at the string...