Here are some example strings:
2222
333333
12345
111
123456789
12345678
The expected result is:
2@222
333@333
12@345
111
123@456@789
12@345@678
In other words, the character '@' should be inserted at the 4th, 8th, 12th, etc. positions counting from the end of the string.
I think this can be achieved using replace and other methods available in JavaScript.
To validate the output string, a regular expression has been created:
^(\d{1,3})(\.\d{3})*?$