Javascript – Mask and insert hyphen after every 3 digits
I am trying to replace the below string like below: var phone = "9871234567" result = xxx-xxx-4567 Below is the js code I have worked upon, but this is not giving me the correct result. var lastphdigit = phone.replace(/d(?=(?:D*d){4})/g, "x");…