This documentation is archived and is not being maintained.

source Property

Updated: July 2009

Returns a copy of the text of the regular expression pattern. Read-only.

rgExp.source

rgExp

Required. A Regular Expression object.

The rgExp can be a variable that stores a Regular Expression object, or it can be a regular expression literal.

The following example illustrates the use of the source property:

var src = "The quick brown fox";
var re = /brown/g;

var s = "";
s += "The string '" + src + "'";

if (re.test(src))
    s += " contains ";
else
    s += " does not contain ";

s += "'" + re.source + "'.";
print (s);

The output of this program is as follows.

The string 'The quick brown fox' contains 'brown'.

Date

History

Reason

July 2009

Modified example.

Content bug fix.

March 2009

Modified example.

Content bug fix.

Show: