JavaScript是一门Web编程语言,用来实现网页的交互功能,它和HTML、CSS共同组成了个Web开发的基础工具集合,也是前端开发者必备的技能;学习JavaScript教程可以了解它在网页开发中的所有特性和相关概念,让我们能够更加快速的去开发Web应用。
这个正则表达式对象的忽略大小写属性:ignoreCase是一个标志,用于指示在字符串的模式匹配过程中是否忽略大小写。若在模式匹配时忽略大小写,则ignoreCase的值为true。如果不区分大小写标志:i 被使用,则为 ignoreCase的值为true,否则为 false。
版本实现
实现于JavaScript 1.2
语法说明
RegExp.ignoreCase
执行一下示例:
以下网页文档演示了如何使用忽略大小写属性:ignoreCase。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<title>JavaScript Regexp ignoreCase Property : Example-1</title>
</head>
<body>
<h1 style="color: red">JavaScript Regexp ignoreCase Property</h1>
<hr />
<script type="text/javascript">
//This is done to make the following JavaScript code compatible to XHTML. <![CDATA[
// A regular expression on the pattern “The”
strpat1 = new RegExp("the","i");
// Declare a string.
str1 = "The Quick Brown Fox Jumps Over The Lazy Dog";
// Executes search for pattern match with exec() and store result in an array array1,array2.
array1 = strpat1.exec(str1);
document.write("The value of RegExp.ignoreCase (for 'the' pattern) is: " + strpat1.ignoreCase);
//]]>
</script>
</body>
</html>
执行一下支持的浏览器
IE浏览器7 | 火狐3.6 | 谷歌Chrome 7 | Safari 5.0.1 版 | Opera 10 |
Yes | Yes | Yes | Yes | Yes |
另请参阅:
上一篇:JavaScript 全局属性(global):正则表达式对象
下一篇:JavaScript lastIndex 属性:RegExp 对象