How to extract the domain name from an email address in TypeScript

1 Answer

0 votes
const email = 'username@emailonline.com';

const domain = email.substring(email.lastIndexOf("@") + 1);

console.log(domain); 

  
  
  
  
/*
run:

"emailonline.com" 
  
*/

 



answered Apr 29, 2022 by avibootz

Related questions

1 answer 176 views
1 answer 138 views
1 answer 175 views
1 answer 186 views
1 answer 166 views
1 answer 199 views
...