RegExp.$n (Property/static)

A property of the global RegExp object.

Availability:

ECMAScript edition - 3
JavaScript - 1.2
JScript - 3.0
Internet Explorer - 4.0
Netscape - 4.0
Netscape Enterprise Server - 3.0
Opera 5.0
JavaScript syntax:-RegExp.$1
-RegExp.$2
-RegExp.$3
-RegExp.$4
-RegExp.$5
-RegExp.$6
-RegExp.$7
-RegExp.$8
-RegExp.$9

There are nine similarly named properties whose name is a dollar symbol followed by a single digit, each of these holding text matched by a sub-expression (in parentheses) for the most recent match.

The ECMAScript edition 3 specification suggests that the range of values for this is $01 to $99 and for an implementation to be ECMA compliant, it should support that range of possibilities. as well as the $1 to $9 values.

Warnings:

See also:RegExp pattern - grouping, RegExp pattern - references, RegExp.exec(), RegExp.test()

Property attributes:

ReadOnly.

Cross-references:

ECMA 262 edition 3 - section - 15.5.4.11