source 屬性
更新:2007 年 11 月
傳回規則運算式模式的文字複本。唯讀。
rgExp.source
引數
- rgExp
必要項。規則運算式物件。
備註
rgExp 可以是一個儲存規則運算式物件的變數,或是一個規則運算式常值。
範例
以下範例說明 source 屬性的用法:
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 string Spain contains in.