Export (0) Print
Expand All

source Property

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

Community Additions

ADD
Show:
© 2014 Microsoft