Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
source Property

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 : String = "Spain";
var re : RegExp = /in/g;
var s1;
// Test string for existence of regular expression.
if (re.test(src))
   s1 = " contains ";
else
   s1 = " does not contain ";
// Get the text of the regular expression itself.
print("The string " + src + s1 + re.source + ".");

The output of this program is:

The string Spain contains in.

Community Additions

ADD
Show:
© 2015 Microsoft