Sdílet prostřednictvím


input Property ($_)

Returns the string against which a regular expression search was performed.

//Syntax 1
{RegExp | reArray}.input

//Syntax 2
RegExp.$_
//The $_ property may be used as shorthand for the input property
//for the RegExp object.

Arguments

  • RegExp
    Required. The global RegExp object.

  • reArray
    Required. An array returned by the exec method of a Regular Expression object.

Remarks

The value of input property is the string against which a regular expression search was performed.

The initial value of the RegExp.input property is an empty string, "". Its value is read-only and changes whenever a successful match is made.

Poznámka

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.

Example

The following example illustrates the use of the input property:

var str = "A test string.";
var re = new RegExp("\\w+","ig");
var arr = re.exec(str);
print("The string used for the match was: " + arr.input);

The output of this program is:

The string used for the match was: A test string.

Requirements

Version 3

Applies To:

RegExp Object

See Also

Reference

exec Method

Concepts

Regular Expression Syntax