富贵资源网 Design By www.hznty.com
本文章来详细介绍js中正则表达式的全局匹配模式 /g用法,代码如下:
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
在创建正则表达式对象时如果使用了“g”标识符或者设置它了的"htmlcode">
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
以上所述是小编给大家介绍的JS中正则表达式全局匹配模式 /g用法详解,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对网站的支持!
富贵资源网 Design By www.hznty.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
富贵资源网 Design By www.hznty.com
暂无评论...