JavaScript正则表达式中的ignoreCase属性使用详解
ignoreCase是正则表达式对象的只读布尔属性。它指定是否一个特定的正则表达式执行不区分大小写的匹配。,它与“i”属性创建。
语法
RegExpObject.ignoreCase
下面是参数的详细信息:
- NA
返回值:
- 如果“i”修改被设置返回“TRUE”,否则返回“FALSE”。
例子:
<html>
<head>
<title>JavaScriptRegExpignoreCaseProperty</title>
</head>
<body>
<scripttype="text/javascript">
varre=newRegExp("string");
if(re.ignoreCase){
document.write("Test1-ignoreCasepropertyisset");
}else{
document.write("Test1-ignoreCasepropertyisnotset");
}
re=newRegExp("string","i");
if(re.ignoreCase){
document.write("<br/>Test2-ignoreCasepropertyisset");
}else{
document.write("<br/>Test2-ignoreCasepropertyisnotset");
}
</script>
</body>
</html>
这将产生以下结果:
Test1-ignoreCasepropertyisnotset Test2-ignoreCasepropertyisset