ignoreCase是RegExp对象的只读布尔属性。 它指定特定的正则表达式是否执行不区分大小写的匹配,即是否使用“i”属性创建。
RegExpObject.ignoreCase
如果设置了“i”修饰符,则返回“ TRUE”,否则返回“ FALSE”。
<html> <head> <title>JavaScript RegExp ignoreCase Property</title> </head> <body> <script type="text/javascript"> var re=new RegExp( "string" ); if ( re.ignoreCase ) { document.write("Test1-ignoreCase property is set"); } else { document.write("Test1-ignoreCase property is not set"); } re=new RegExp( "string", "i" ); if ( re.ignoreCase ) { document.write("<br/>Test2-ignoreCase property is set"); } else { document.write("<br/>Test2-ignoreCase property is not set"); } </script> </body> </html>
运行上面代码输出
Test1 - ignoreCase property is not set Test2 - ignoreCase property is set
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)