©
Dieses Dokument verwendetPHP-Handbuch für chinesische WebsitesFreigeben
| JScript | 语言参考 |
返回 Boolean 值,指出正则表达式使用的 ignoreCase 标志(i) 的状态。默认值为false。只读。
rgExp.ignoreCase
必选项rgExp参数为RegExp对象。
如果正则表达式设置了 ignoreCase 标志,那么ignoreCase属性返回true,否则返回false。
如果使用了 ignoreCase 标志,那就表明在被查找的字符串中匹配样式的时候查找操作将不区分大小写。
以下示例演示了ignoreCase属性的用法。如果传递 "i" 到下面所示的函数中,那么所有的单词 "the" 将被 "a" 替换,包括最开始位置上的 "The"。这是因为设置了 ignoreCase 标志,搜索操作将不区分大小写。所以在进行匹配的时候 "T" 与 "t" 是等价的。
此函数返回一个字符串以及一个表,表中显示了与允许使用的正则表达式标志(g、i和m)相关的属性值。它还返回经过所有替换操作后的字符串。
function RegExpPropDemo(flag){ if (flag.match(/[^gim]/)) //检查标志的有效性。return("Flag specified is not valid");var r, re, s //声明变量。var ss = "The man hit the ball with the bat.\n";ss += "while the fielder caught the ball with the glove.";re = new RegExp("the",flag); //指定要查找的样式。r = ss.replace(re, "a"); //利用"a"替换"the"。s = "Regular Expression property values:\n\n"s += "global ignoreCase multiline\n"if (re.global) //测试global标志。s += " True ";elses += "False ";if (re.ignoreCase) //测试ignoreCase标志。s += " True ";elses += "False ";if (re.multiline) //测试multiline标志。s += " True ";elses += " False ";s += "\n\nThe resulting string is:\n\n" + r;return(s); //返回替换的字符串 }
版本 5.5
global 属性 | multiline 属性 | 正则表达式语法
应用于:RegExp 对象