Remove all occurrences except last?

You can use regex with positive look ahead,

"1.2.3.4".replace(/[.](?=.*[.])/g, "");

Leave a Comment