Answers for "js exec vs match"

1

js exec vs match

/*
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);
}
Posted by: Guest on October-11-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language