Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Obfuscate email addresses in TextMate (See related posts)

// Textmate / e command for obfuscating email addresses

#!/usr/bin/env ruby

email = STDIN.read
url_email = email.gsub(/./) { |c| '%' + c.unpack('H2' * c.size).join('%').upcase }
html_email = url_email[1..-1].split(/%/).collect { |c| sprintf("&#%03d;", c.to_i(16)) }.join

print "<a href=\"mailto:#{url_email}\">#{html_email}</a>"

You need to create an account or log in to post comments to this site.


Click here to browse all 5147 code snippets

Related Posts