Platinum Partner

Ruby Method To Extract Emails From A String Into An Array

self.explain



def extract_emails_to_array(txt)
  reg = /[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}/i
  txt.scan(reg).uniq
end


input = IO.readlines("in.txt")
output = File.new("mails.txt",  "w+") 


result_array = extract_emails_to_array(input.join(" ")).sort
puts result_array.size  #optional

result_array.each{|s| output << s.to_s+"\n" }


{{ tag }}, {{tag}},

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}
{{ parent.authors[0].realName || parent.author}}

{{ parent.authors[0].tagline || parent.tagline }}

{{ parent.views }} ViewsClicks
Tweet

{{parent.nComments}}