Export (0) Print
Expand All

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.

RegExp

Required. The global RegExp object.

reArray

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

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.

NoteNote

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 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.

Community Additions

ADD
Show:
© 2014 Microsoft