I want to increment a number each time string.replace() replace a sub-string. for example in:
var string = "This is this";
var number = 0;
string.replace("is", "as");
When string.replace first is of This
number becomes 1
, then for second is of is
number becomes 2
and finally for last is of this
number becomes 3
.
Thanks in advance...! :-)