Returns the nine most-recently memorized portions found during pattern matching. Read-only.
RegExp.$n |
Arguments
- RegExp
-
Required. The global RegExp object.
n
Required. An 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 properties of the RegExp object are not available when running in fast mode, the default for JScript. To compile a program from the command line that uses these properties, 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 s : String; var re : RegExp = new RegExp("d(b+)(d)","ig"); var str : String = "cdbBdbsbdbdz"; var arr : Array = re.exec(str); s = "$1 contains: " + RegExp.$1 + "\n"; s += "$2 contains: " + RegExp.$2 + "\n"; s += "$3 contains: " + RegExp.$3; print(s); |
After compiling with the /fast- option, the output of this program is:
В | ![]() |
---|---|
$1 contains: bB $2 contains: d $3 contains: |
Requirements
Applies To:
See Also
Concepts
