When I have something like this:
var str = "0123"; var i = 0; str.replace(/(\d)/g,function(s){i++;return s;}('$1')); alert(i);
Why is "i" equal to 1, not 4? Also, is it possible to pass the actual value of $ 1 to a function (in this case, 0,1,2,3)?
javascript function regex replace
Kebabbi
source share