I have a string consisting of 15 digits. For example, 347405405655278
. I need to add a blank space after the 4th digit and then after the 10th digit making it look like 3474 054056 55278
. Can I achieve this using a regular expression?
With the help of regular expression, you can use the given below code to achieve the desired result:
var result = "347405405655278".replace(/^(.{4})(.{6})(.*)$/, "$1 $2 $3");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With