source Property
Returns a copy of the text of the regular expression pattern. Read-only.
rgExp.source
Arguments
- rgExp
Required. A Regular Expression object.
Remarks
The rgExp can be a variable that stores a Regular Expression object, or it can be a regular expression literal.
Example
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'.