I expect a string of just numbers from HTML inputbox but i am looking for a regex so that i can capture some part of string and replace it with something and now what i want is, for next iteration, regex should skip part which has been processed.
Take a look at my regex
string.replace(/([\d]{10})/gm, "$1,")
Expected results for iterations
- 895645784578457845784578457845
source - 8956457845,7845784578,4578457845,9089
more data is coming
But problem is result
- 8956457845,7845784578,4578457845
- 8956457845,,,7845784578,,,4578457845,,,9089
"895645784578457845784578457845".replace(/([\d]{10})/gm, "$1,")returns"8956457845,7845784578,4578457845,"as one would expect.[\d]is just a long way to write\d. :-)/(\d{10}(?!\,))/gm, like this fiddle