Share via


input 屬性 ($_)

更新:2007 年 11 月

依據所執行的規則運算式搜尋傳回字串。

//Syntax 1
{RegExp | reArray}.input

//Syntax 2
RegExp.$_
//The $_ property may be used as shorthand for the input property
//for the RegExp object.

引數

  • RegExp
    必要項。全域 RegExp 物件。

  • reArray
    必要項。規則運算式物件的 exec 方法所傳回的陣列。

備註

input 屬性 (Property) 的值是執行規則運算式搜尋時所用的字串。

RegExp.input 屬性的初始值是空字串 ("")。它的值是唯讀的,且會隨著找到符合的項目而變更。

注意事項:

當以 JScript 預設的快速模式執行時,無法使用 RegExp 物件的屬性。若要從命令列編譯使用這些屬性的程式,必須使用 /fast- 關閉快速選項。因為執行緒的問題,在 ASP.NET 中關閉快速選項並不安全。

範例

以下範例說明 input 屬性的用法:

var str : String = "A test string.";
var re : RegExp = new RegExp("\\w+","ig");
var arr : Array = re.exec(str);
print("The string used for the match was: " + arr.input);

本程式的輸出為:

The string used for the match was: A test string.

需求

3 版

套用至:

RegExp 物件

請參閱

概念

規則運算式語法

參考

exec 方法