ChatterBank6 mins ago
Multiple Email question
13 Answers
I have a document online that has multiple email address' in different fields. Instead of having to actually click every single one, is there a way to just copy all the email address' on the page with just one click? There is text in between each email address...so if you use the "select all" button, it selects everything. And, i just want the email address. There are probably 1,000 email address' on the one page.
Answers
Best Answer
No best answer has yet been selected by exitjamie. Once a best answer has been selected, it will be shown here.
For more on marking an answer as the "Best Answer", please visit our FAQ.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
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
OK, I've found a way to make it easy to use. Follow these steps to try it:
1) Highlight your text in whatever document you have, copy it to the clipboard, and then open notepad (programs -> accessories I think), and paste it in there. Should just be plain text, very boring.
2) goto this site:
http://www.ruby.ch/interpreter/rubyinterpreter .shtml
3) copy and paste the following script into the box on that site, exactly.
######################
file = "
"
#email_addresses = File.new("email_addresses.txt","w")
email_string = ""
file.each_line do |line|
if line =~ /\b(\w[\w+.]*@\w[\w.]+\w+)\b/ix
m = line.scan(/(\w[\w+.]*@\w[\w.]+\w+)+/i)
email_string += m.join(" ") + " "
end
end
puts email_string
######################
4) copy and paste the plain text from in notepad to the gap between where it says file " ...... " at the top of the above script. (Just put them on a new line in between the double-quote characters).
5) Press interpret. You'll get a popup window, which should give you a long list of all your email addresses, all on their own.
1) Highlight your text in whatever document you have, copy it to the clipboard, and then open notepad (programs -> accessories I think), and paste it in there. Should just be plain text, very boring.
2) goto this site:
http://www.ruby.ch/interpreter/rubyinterpreter .shtml
3) copy and paste the following script into the box on that site, exactly.
######################
file = "
"
#email_addresses = File.new("email_addresses.txt","w")
email_string = ""
file.each_line do |line|
if line =~ /\b(\w[\w+.]*@\w[\w.]+\w+)\b/ix
m = line.scan(/(\w[\w+.]*@\w[\w.]+\w+)+/i)
email_string += m.join(" ") + " "
end
end
puts email_string
######################
4) copy and paste the plain text from in notepad to the gap between where it says file " ...... " at the top of the above script. (Just put them on a new line in between the double-quote characters).
5) Press interpret. You'll get a popup window, which should give you a long list of all your email addresses, all on their own.
Tip:
Do as I say above, but first try the random text (with a few email addresses) that I put above...
I've just tried it and I get
[email protected] [email protected] [email protected] [email protected] [email protected]
Bingo!
Do as I say above, but first try the random text (with a few email addresses) that I put above...
I've just tried it and I get
[email protected] [email protected] [email protected] [email protected] [email protected]
Bingo!
You're welcome :)
This also does several email addresses on one line too, I remembered how to do it.
Finally, There are two lines in the above script that look like these:
######
if line =~ /\b(\w[-\w+.]*@\w[-\w.]+\w+)\b/i
m = line.scan(/(\w[-\w+.]*@\w[-\w.]+\w+)/i)
######
Replace them with the above lines in this answer, and the script will understand email addresses with hyphens in them too. The old script would fail for emails like [email protected]. This new one likes them.
This isn't essential, I've just noticed it.
This also does several email addresses on one line too, I remembered how to do it.
Finally, There are two lines in the above script that look like these:
######
if line =~ /\b(\w[-\w+.]*@\w[-\w.]+\w+)\b/i
m = line.scan(/(\w[-\w+.]*@\w[-\w.]+\w+)/i)
######
Replace them with the above lines in this answer, and the script will understand email addresses with hyphens in them too. The old script would fail for emails like [email protected]. This new one likes them.
This isn't essential, I've just noticed it.