From: Robert Klemme Date: 2007-01-04T21:40:06+09:00 Subject: Re: scan string w regex .. and HNYTAOY ! On 04.01.2007 13:07, Mat Schaffer wrote: > On Jan 4, 2007, at 6:55 AM, Josselin wrote: >> forgot to mention what I wwrote until now : >> >>> to_string.split(%r{\r\n\s*}) which gives me teh addresses separated >>> by \r\n , but I missed the addresses separated by spaces > > I would just scan for email addresses. Yeah, that's what I'd also prefer over splitting. > I got this: > to_string.scan(/[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}/i) > > From this site: > http://www.regular-expressions.info/email.html > > Which seems to do the job reasonably well. Hm, IMHO the domain part could be a bit better with respect to dots. Something like (?:[A-Z0-9-]+\.)+[A-Z]{2,4} In some circumstances something simple like this will even work [^\s@]+@[^\s@]+ And I bet there is a ton of variants... Cheers robert