Bagikan melalui


rightContext Property ($')

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

RegExp.rightContext

Arguments

  • RegExp
    Required. The global RegExp object.

Remarks

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

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.

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

Example

The following example illustrates the use of the rightContext property:

// Create the regular expression pattern.
var re = new RegExp("d(b)(d)","ig");
var str = "cdbBdbsbdbdz";

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

// Print the output.
var s = "" 
s += "$1: " + RegExp.$1 + "\n";
s += "$2: " + RegExp.$2 + "\n";
s += "$3: " + RegExp.$3 + "\n";
s += "input: " + RegExp.input + "\n";
s += "lastMatch: " + RegExp.lastMatch + "\n";
s += "leftContext: " + RegExp.leftContext + "\n";
s += "rightContext: " + RegExp.rightContext + "\n"; 
s += "lastParen: " + RegExp.lastParen + "\n";

The output of this program is as follows:

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

Requirements

Version 5.5

Applies To:

RegExp Object

See Also

Reference

$1...$9 Properties

index Property

input Property ($_)

lastIndex Property

lastMatch Property ($&)

lastParen Property ($)

leftContext Property ($`)

Change History

Date

History

Reason

July 2009

Modified example.

Content bug fix.

July 2009

Modified note about the /fast option.

Content bug fix.

March 2009

Modified example.

Information enhancement.