Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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);
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #js #exec #match
ADD COMMENT
Topic
Name
4+7 =