$1...$9 Properties

Returns the nine most-recently memorized portions found during pattern matching. Read-only.

RegExp.$n 

Arguments

  • RegExp
    Required. The global RegExp object.

  • n
    Required. Any integer from 1 through 9.

Remarks

The value of the $1...$9 properties is modified whenever a successful parenthesized match is made. Any number of parenthesized substrings may be specified in a regular expression pattern, but only the nine most recent can be stored.

Note

The properties of the RegExp object are not available when a program is running in fast mode, the default for JScript. To compile a program that uses these properties from a command prompt, you must turn off the fast option by using /fast-. It is not safe to turn off the fast option in ASP.NET because of threading issues.

Example

The following example illustrates the use of the $1...$9 properties:

var newline = "\n"

var re = new RegExp("d(b+)(d)","ig");
var str = "cdbBdbsbdbdz";
var arr = re.exec(str);

var s = "";
s += "$1 contains: " + RegExp.$1;
s += newline;
s += "$2 contains: " + RegExp.$2;
s += newline;
s += "$3 contains: " + RegExp.$3;

The output of this program is as follows.

$1 contains: bB
$2 contains: d
$3 contains:

Requirements

Version 1

Applies To:

RegExp Object

See Also

Concepts

Regular Expression Syntax