JavaScript tutorial:
input property

 

Applies To: RegExp Object

The input property returns the string against which a search was performed. Read-only.

Syntax

RegExp.input

Return String

Returns the string against which a search was performed.

Remarks

The value of input property is modified any time the searched string is changed.

The following example illustrates the use of the input property:

function inputDemo()
{
var s;
var re = new RegExp("d(b+)(d)","ig");
var str = "cdbBdbsbdbdz";
var arr = re.exec(str);
s = "The string used for the match was " + RegExp.input;
return(s);
}
document.write(inputDemo());
To run the code, paste it into JavaScript Editor, and click the Execute button.

See Also: RegExp Object Properties, Regular Expression Syntax