0

i have bulk of email address in textarea '[email protected]@[email protected]@[email protected]@hotmail.com'

what i want to do is add 'comma space' behind of .com / .com.my

expected result after onblur function in textarea: `[email protected], [email protected], [email protected], [email protected], [email protected], [email protected]

what i have tried.

b = value.split('.com.my').join('.com.my, ');
b = value.split('.com').join('.com, ');

problem : it will replace all '.com' to '.com, ' even with '.com.my'

0

1 Answer 1

3

var value = "[email protected]@[email protected]@[email protected]@hotmail.com";
value = value.replace(/(.com(.my)?)/gm, '$1, ');
console.log(value.substring(0, value.length - 2));

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.