Share via


lastParen Property ($+) (JScript 5.6) 

Returns the last parenthesized submatch from any regular expression search, if any. Read-only.


RegExp.lastParen

Remarks

The object associated with this property is always the global RegExp object.

The initial value of the lastParen property is an empty string. The value of the lastParen property changes whenever a successful match is made.

Example

The following example illustrates the use of the lastParen property:

function matchDemo(){

   var s;                                //Declare variable.

   var re = new RegExp("d(b+)(d)","ig"); //Regular expression pattern.

   var str = "cdbBdbsbdbdz";             //String to be searched.

   var arr = re.exec(str);               //Perform the search.

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

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

   s += "$3 returns: " + RegExp.$3 + "\n";

   s += "input returns : " + RegExp.input + "\n";

   s += "lastMatch returns: " + RegExp.lastMatch + "\n";

   s += "leftContext returns: " + RegExp.leftContext + "\n";

   s += "rightContext returns: " + RegExp.rightContext + "\n"; 

   s += "lastParen returns: " + RegExp.lastParen + "\n";

   return(s);                            //Return results.

}

document.write(matchDemo());

Requirements

Version 5.5

Applies To: RegExp Object (JScript 5.6)

See Also

Reference

$1...$9 Properties (JScript 5.6)
index Property (JScript 5.6)
input Property ($_) (JScript 5.6)
lastIndex Property (JScript 5.6)
lastMatch Property ($&) (JScript 5.6)
leftContext Property ($`) (JScript 5.6)
rightContext Property ($') (JScript 5.6)