Share via


ignoreCase 屬性

更新:2007 年 11 月

傳回布林值,該布林值表示規則運算式所使用之 ignoreCase 旗標 (i) 的狀態。

 rgExp.ignoreCase

引數

  • rgExp
    必要項。規則運算式物件的執行個體。

備註

ignoreCase 的屬性是唯讀的,如果已設定規則運算式的 ignoreCase 旗標,就會傳回 true,否則傳回 false。預設值是 false

若使用 ignoreCase 旗標,表示搜尋功能在搜尋字串內比對模式時應該不區分大小寫。

範例

以下範例示範 ignoreCase 屬性的用法。

function RegExpPropDemo(re : RegExp) {
   print("Regular expression: " + re);
   print("global:     " + re.global);
   print("ignoreCase: " + re.ignoreCase);
   print("multiline:  " + re.multiline);
   print();
};

// Some regular expression to test the function.
var re1 : RegExp = new RegExp("the","i");  // Use the constructor.
var re2 = /\w+/gm;                         // Use a literal.
RegExpPropDemo(re1);
RegExpPropDemo(re2);
RegExpPropDemo(/^\s*$/im);

本程式的輸出為:

Regular expression: /the/i
global:     false
ignoreCase: true
multiline:  false

Regular expression: /\w+/gm
global:     true
ignoreCase: false
multiline:  true

Regular expression: /^\s*$/im
global:     false
ignoreCase: true
multiline:  true

需求

5.5 版

套用至:

規則運算式物件

請參閱

概念

規則運算式語法

參考

global 屬性

multiline 屬性