[JavaScript] Extract Only the Domain Part After @ from Email Address
I’ll introduce JavaScript code that extracts only the domain part after @ from an email address.
Using the String.prototype.split() method, you can extract only the domain part after @ from an email address with the following code:
var emailAddress = '[email protected]';
var emailDomain = emailAddress.split('@')[1];
console.log(emailDomain);
// 'exaple.com'
You could also extract it using regular expressions, but this time I wrote code using the split method, prioritizing clarity.
That’s all from the Gemba.