Share via


$1...$9 Properties (JScript 5.6) 

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


RegExp.$n 

Arguments

  • RegExp
    Always the global RegExp object.

n

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.

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

function matchDemo(){

   var s;

   var re = new RegExp("d(b+)(d)","ig");

   var str = "cdbBdbsbdbdz";

   var arr = re.exec(str);

   s = "$1 contains: " + RegExp.$1 + "\n";

   s += "$2 contains: " + RegExp.$2 + "\n";

   s += "$3 contains: " + RegExp.$3;

   return(s);

}

Requirements

Version 1

Applies To: RegExp Object (JScript 5.6)

See Also

Reference

Regular Expression Syntax (Scripting)