var text = "cat, bat, sat, fat";var pattern2 = /.at/g;var matches = pattern2.exec(text);console.log(matches.index); //0console.log(matches[0]); //catconsole.log(pattern2.lastIndex); //3matches = pattern2.exec(text);console.log(matches.index); //5,为什么是5,不应该从fat开始吗?console.log(matches[0]); //batconsole.log(pattern2.lastIndex); //8为什么后面从bat开始,不应该从fat开始吗?
添加回答
举报
0/150
提交
取消