Example strings :
2222
333333
12345
111
123456789
12345678
Expected result:
2@222
333@333
12@345
111
123@456@789
12@345@678
i.e. '@' should be inserted at the 4th,8th,12th etc last position from the end of the string.
I believe this can be done using replace and some other methods in JavaScript.
for validation of output string i have made the regex :
^(\d{1,3})(\.\d{3})*?$
.in it ? can you please explain ?