1 2 3 4 5 6 | var str = "123#abc"; var re = /abc/ig; console.log(re.test(str)); //输出ture console.log(re.test(str)); //输出false console.log(re.test(str)); //输出ture console.log(re.test(str)); //输出false |
1 2 3 4 5 6 7 8 9 10 | var str = "123#abc"; var re = /abc/ig; console.log(re.test(str)); //输出ture console.log(re.lastIndex); //输出7 console.log(re.test(str)); //输出false console.log(re.lastIndex); //输出0 console.log(re.test(str)); //输出ture console.log(re.lastIndex); //输出7 console.log(re.test(str)); //输出false console.log(re.lastIndex); //输出0 |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |