OK just written this in a minute or so.
It takes a text file (plain text -- copy and paste your text into a notepad file, save it as data.txt). I also can't for the life of me remember how to match several email addresses on the same line -- so just go through and press return after each address to make it into a new line.
If your data.txt file now looks something like this:
one
[email protected] oj0 09 grk iuhgkr df
twooigj f fg uoghd9y dlfd gldf
[email protected] is here. three iof g9d8f yng43 o9
four ogfu h0g8
[email protected] oig 89 kjg ndkfjg dfg 89 ofd g9df
five 04 godfg 0fd
[email protected],
[email protected]
six09 0tr 8kjgfh ghfgkhgk
seven 0 gkj hkjg kf
eight
nine
ten
Then you can run the following ruby script to grab the email addresses out of it:
#!/usr/local/bin/ruby -w
file = File.new("data.txt")
email_addresses = File.new("email_addresses.txt","w")
file.each do |line|
if line =~ /\b(\w[\w+.]*@\w[\w.]+\w+)\b/ix
email_addresses.print $1, " "
end
end
And it'll give your the addresses, separated by a space, in the file email_addresses.txt.
I'll leave the running of this file as an exercise to the reader :P