An Interest In:
Web News this Week
- April 13, 2024
- April 12, 2024
- April 11, 2024
- April 10, 2024
- April 9, 2024
- April 8, 2024
- April 7, 2024
September 22, 2021 06:05 am GMT
Original Link: https://dev.to/101samovar/how-to-extract-email-address-from-a-string-2h7e
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:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To