JavaScript 中忽略大小写 RegExp 属性的作用是什么?
ignoreCase 是 RegExp 对象的只读布尔属性。它指定特定的正则表达式是否执行不区分大小写的匹配,即是否使用“i”属性创建的。
示例
你可以尝试运行以下代码,了解如何在 JavaScript 中使用忽略大小写的 RegExp 属性。
<html>
<head>
<title>JavaScript RegExp ignoreCase Property</title>
</head>
<body>
<script>
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>
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP