Skip to content

Instantly share code, notes, and snippets.

@chikoski
Created June 17, 2014 08:42
Show Gist options
  • Select an option

  • Save chikoski/91e32bdb5f70e3df3351 to your computer and use it in GitHub Desktop.

Select an option

Save chikoski/91e32bdb5f70e3df3351 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
pattern = /^(?:(?:(?:(?:[a-zA-Z0-9_!#\$\%&'*+\/=?\^`{}~|\-]+)(?:\.(?:[a-zA-Z0-9_!#\$\%&'*+\/=?\^`{}~|\-]+))*)|(?:"(?:\\[^\r\n]|[^\\"])*")))\@(?:(?:(?:(?:[a-zA-Z0-9_!#\$\%&'*+\/=?\^`{}~|\-]+)(?:\.(?:[a-zA-Z0-9_!#\$\%&'*+\/=?\^`{}~|\-]+))*)|(?:\[(?:\\\S|[\x21-\x5a\x5e-\x7e])*\])))$/
table = {}
open(ARGV.shift) do |fd|
fd.each do |line|
date, mail = line.split(/,/)
table[mail] = date if mail =~ pattern
end
end
puts table.keys.map{|mail|
"#{table[mail]},#{mail}"
}.sort.join("")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment