题目17:Read the following javascript code: var someText="web2.0 .net2.0";var pattern=/(\w+)(\d)\.(\d)/g;var outCome_exec=pattern.exec(someText);var outCome_matc=someText.match(pattern); What is outCome_exec[1] and outCome_matc[1]? Choice A: true C…
阅读本文之前,请先看下面一道题: 题目17:Read the following javascript code: var someText="web2.0 .net2.0"; var pattern=/(\w+)(\d)\.(\d)/g; var outCome_exec=pattern.exec(someText); var outCome_matc=someText.match(pattern); What is outCome_exec[1] and outCome_matc…
分几种情况说明 1.假设re中不是全局的也就是不带g var str = "cat3 hat4"; var re = /\w+\d/; var ex = re.exec(str); var mt = str.match(re); console.log(ex); console.log(mt); 结果是["cat3"] 也就是说假设不带g的情况那么..这2个返回的一样 那么就是exec和match 不是全局的时候都是返回匹配到的第一个假设没有返回null 2.假设r…
test.exec.match的简单区别 1.test test 返回 Boolean,查找对应的字符串中是否存在模式. var str = "1a1b1c"; var reg = new RegExp("1.", ""); alert(reg.test(str)); // true 2.exec exec 查找并返回当前的匹配结果,并以数组的形式返回. var str = "1a1b1c"; var reg = new Re…