Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
September 22, 2021 06:05 am GMT

How to extract email-address from a string?

There is a string that contains email addresses.
To get the email addresses we need the match method.
The match method with a regular expression pattern for email addresses.
This pattern suppose that the email address consists of login name, at-symbol and domain name.
Login name can be combined from letters in lower and upper case, digits and underscore symbol.
Domain name should consist of two parts separated with a dot symbol.

let string = 'manager: [email protected]; sales: [email protected]';let emailList = string.match(/[\w]+@[\w\-]+\.[\w]{2,}/g);console.log(emailList);

So we have got an array with email addresses from the string.

I hope you found this article useful, if you need any help please let me know in the comment section.

See you next time. Have a nice day!

Subscribe to our channel:
https://www.youtube.com/c/Samovar101


Original Link: https://dev.to/101samovar/how-to-extract-email-address-from-a-string-2h7e

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To