Regular Expression Properties

The following table displays a summary of the regular expression properties. Note that several of these properties have both long and short (Perl-like) names. Both names always refer to the same value. Perl is the programming language from which JavaScript modeled its regular expressions. Detailed descriptions of each property follow the table.

PropertyDescription

$1, ..., $9

Parenthesized substring matches, if any.

$_

See input.

$*

See multiline.

$&

See lastMatch.

$+

See lastParen.

$'

See leftContext.

$'

See rightContext.

global

Whether to test the regular expression against all possible matches in a string, or only against the first.

ignoreCase

Whether to ignore case while attempting a match in a string.

input

The string against which a regular expression is matched.

lastIndex

The index at which to start the next match.

lastMatch

The last matched characters.

lastParen

The last parenthesized substring match, if any.

leftContext

The substring preceding the most recent match.

multiline

Whether to search in strings across multiple lines.

rightContext

The substring following the most recent match.

source

The text of the pattern.