I need to extract a single email address from this kind of string.
Unauthorized: Your password has expired. We have sent a reset password link to example@gmail.com. Please check your email for details
const string = "Unauthorized: Your password has expired. We have sent a reset password link to example@gmail.com. Please check your email for details";
const mailMatch = string.match(/(\S+@[^\s.]+\.{1}[^.]\S+)/);
The match in this case will be this `
[0: "example@gmail.com."
1: "example@gmail.com."
groups: undefined
index: 79
input: "Unauthorized: Your password has expired. We have sent a reset password link to example@gmail.com. Please check your email for details"
length: 2]
I don't want to match the dot(indicating end of the sentence) at the end of mail.
How to change my regexp , in order to get only example@gmail.com