1
在以下代码中,我使用RegExp检查E
,其中字符串敏感修饰符i
在字符串The best things in life are free
中。但即使字符串中没有大写字母E
,它也会返回true
。带有区分大小写的修饰符的JavaScript中的RegExp
<html>
<body>
<script type="text/javascript">
var patt1=new RegExp("E","i");
document.write(patt1.test("The best things in life are free"));
</script>
</body>
</html>
的* I *代表 “不区分大小写”。 – Gumbo 2012-02-12 12:14:26
@Gumbo那是什么问题。 RegExp应该返回'false',因为字符串中没有大写'E''生命中最好的东西都是免费的' – sandbox 2012-02-12 12:18:21