This topic has not yet been rated - Rate this topic

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.
Did you find this helpful?
(1500 characters remaining)

Community Additions

ADD
© 2013 Microsoft. All rights reserved.