RegExp : Object
String
s.Instance Properties
true
if the RegExp
was created with the 's'
flag. DotAll RegExp
s will match any character for '.'
including new lines ('\r'
or '\n'
) which do not match '.'
by default. Another option is to replace '.'
with an empty inverted character class match '[^]'
for systems that do not support ECMAScript 2018. See also multiline
.
Example:
RunResults:
true
if the RegExp
was created with the 'g'
flag. Global RegExp
s will match each place this.source
occurs in the string, not just the first match. See also String.matchAll().
Example:
RunResults:
true
if the RegExp
was created with the 'i'
flag. IgnoreCase RegExp
s will do case insensitive matching.
Example:
RunResults:
true
if the RegExp
was created with the 'm'
flag. Multiline RegExp
s will match '^'
to the beginning of lines as well as the beginning of the string and match '$'
to the end of lines as well as the end of the string. Note that multiline
does not affect the '.'
character class. See dotAll
for more details.
Example:
RunResults:
Instance Methods
If this
matches str
, returns a new Array
with item 0
equal to the portion of str
that matched the regular expression, item 1
equal to the first capturing group in this
, item 2
equal to the second capturing group in this
, and so on. If this
doesn't match str
, returns null
. See also String.match().
Example:
RunResults:
You can name capture groups by placing ?<name>
at the start of the group. The captured values are available on a groups
property on the returned array. Note, this is new with ECMAScript 2018.
Example:
RunResults:
If this
is a global
RegExp, exec
can be called repeatedly to get all matches. Each time it is called, it updates this.lastIndex
and begins the search from there. When there are no more matches, returns null
. See also String.matchAll().