Given the following input:
123456781234567812345678
I am trying to do the following:
12345678,12345678,12345678
Currently, work on doing this is currently reading as:
parts = parts.replace(/\B(?=(\d{8})+(?!\d))/g, ",");
The problem I get is that the regular expression is read from right to left. I created JSFIDDLE to show the problem. As a result, I get something like this.
123,45678910,12345678
Finally, when I use the arrow keys to move, it brings me back to the end of the input.
REGEX101
javascript jquery regex
Dot batch
source share