How can I create an array of email addresses contained within a block of text? I’ve tried
addrs = text.scan(/ .+?@.+? /).map{|e| e[1...-1]}
but (not surprisingly) it doesn’t work reliably.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Howabout this for a (slightly) better regular expression
You can find this here:
Email Regex
Just an FYI, the problem with your email is that you allow only one type of separator before or after an email address. You would match ‘@’ alone, if separated by spaces.