一个数组内有几个重复元素,使用相同的正则去test();相同元素返回的结果一个是true一个却是false。
请教各位前辈该问题原因出在哪里?
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>index测试</title>
</head>
<body>
<script>
window.onload = function () {
var test1_reg = /(\[(NO)|(OK)+|\[[\u4e00-\u9fa5]{1,3}\])/g;
var new_arry2 = ['[微123笑]123', '[色]', '[123流泪][呲123牙]', '[色]', '[色]', 123, '[色]', '[色]', '[色]', '[色]'];
document.write(new_arry2 + '<br/>' + '<br/>');
document.write(test1_reg.test(new_arry2[0]) + '===' + new_arry2[0] + '<br/>');
document.write(test1_reg.test(new_arry2[1]) + '===' + new_arry2[1] + '<br/>');
document.write(test1_reg.test(new_arry2[2]) + '===' + new_arry2[2] + '<br/>');
document.write(test1_reg.test(new_arry2[3]) + '===' + new_arry2[3] + '<br/>');
document.write(test1_reg.test(new_arry2[4]) + '===' + new_arry2[4] + '<br/>');
document.write(test1_reg.test(new_arry2[5]) + '===' + new_arry2[5] + '<br/>');
document.write(test1_reg.test(new_arry2[6]) + '===' + new_arry2[6] + '<br/>');
document.write(test1_reg.test(new_arry2[8]) + '===' + new_arry2[8] + '<br/>');
document.write(test1_reg.test(new_arry2[9]) + '===' + new_arry2[9] + '<br/>');
};
</script>
</body>
</html>
慕姐4208626
相关分类