Javascript - Regexp Regexp Type

Introduction

ECMAScript supports regular expressions through the RegExp type.

Regular expressions can be created using following syntax:

var expression = /pattern/flags;

The pattern can be any 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:

Item Meaning
gglobal mode, the pattern will be applied to all of the string instead of stopping after the first match is found.
i case-insensitive mode, the string case is ignored when determining matches.
m multiline mode, the pattern will continue looking for matches after reaching the end of one line of text.