Export (0) Print
Expand All

rightContext Property ($') 

Returns the characters from the position following the last match to the end of the searched string. Read-only.


RegExp.rightContext

RegExp

Required. The global RegExp object.

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

NoteNote

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.

The short form for the rightContext property is $'. The expressions RegExp["$'"] and RegExp.rightContext can be used interchangeably.

The following example illustrates the use of the rightContext property:

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";
print(s);                            //Return results.

After compiling this program with the /fast- option, the output of this program is:

$1 returns: bB
$2 returns: d
$3 returns:
input returns : cdbBdbsbdbdz
lastMatch returns: dbBd
leftContext returns: c
rightContext returns: bsbdbdz
lastParen returns: d

Community Additions

ADD
Show:
© 2014 Microsoft