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

Requirements

Version 3

Applies To:

Regular Expression Object

See Also

Concepts

Regular Expression Syntax

Reference

Regular Expression Object

Change History

Date

History

Reason

July 2009

Modified example.

Content bug fix.

March 2009

Modified example.

Content bug fix.