发布网友 发布时间:2022-04-27 10:35
共5个回答
热心网友 时间:2022-04-22 23:25
下面详解。
<pre name="code" class="html"><!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>统计包含“a”或“A”的字符串的个数</title>
<script type="text/javascript">
var countryList=["America","Greece","Britain","Canada","China","Egypt"];
var count=0;
document.write("在以下字符中:<br/>");
for(var i in countryList){
document.write(countryList[i]+"<br/>");
if(countryList[i].indexOf("a")!=-1||countryList[i].indexOf("A")!=-1)
count++;
}
document.write("共有"+count+"个字符中串包含a或A。");
</script>
</head>
<body>
</body>
</html>
参考资料
1111的博客.1111的博客[引用时间2018-1-24]
热心网友 时间:2022-04-23 00:43
<!DOCTYPE html>热心网友 时间:2022-04-23 02:18
var str="aAsdadA";热心网友 时间:2022-04-23 04:09
var reg = /[A]/g;热心网友 时间:2022-04-23 06:17
<script>