RegExp Object

RegExp Object

An intrinsic global object that stores information about the results of regular expression pattern matches. This object cannot be constructed explicitly.

The RegExp object has no methods.

The RegExp object cannot be created directly, but it is always available. Until a successful regular expression search has been completed, the initial values of the various properties of the RegExp object are as follows:



Initial Value






Empty string






Empty string.



Empty string.



Empty string.



Empty string.

$1 - $9


Empty string.

The global RegExp object should not be confused with the Regular Expression object. Although they sound similar, they are separate and distinct. The properties of the global RegExp object contain continually updated information about each match as it occurs, while the properties of the Regular Expression object contain only information about the matches that occur with a single instance of the Regular Expression.


The properties of RegExp 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 following example illustrates the use of the global RegExp object. This example must be compiled with the /fast- option.

var re : RegExp = new RegExp("d(b+)(d)","ig");
var arr : Array = re.exec("cdbBdbsbdbdz");
print("$1 contains: " + RegExp.$1);
print("$2 contains: " + RegExp.$2);
print("$3 contains: " + RegExp.$3);

The output from this code is:

$1 contains: bB
$2 contains: d
$3 contains:

Community Additions

© 2015 Microsoft