📜  js exec vs match - Javascript代码示例

📅  最后修改于: 2022-03-11 15:02:50.678000             🧑  作者: Mango

代码示例1
/*
The main difference between string.match and regex.exec is,
the regex object will be updated of the current match with
regex.exec call.
For example,
*/

var myString = "[22].[44].[33].", myRegexp = /\d+/g, result;

while (result = myRegexp.exec(myString)) {
    console.log(result, myRegexp.lastIndex);
}