Skip to content

Instantly share code, notes, and snippets.

@johnkoht
Created February 26, 2013 00:21
Show Gist options
  • Save johnkoht/5034647 to your computer and use it in GitHub Desktop.
Save johnkoht/5034647 to your computer and use it in GitHub Desktop.
Little script that takes a string and will return the same string but with email addresses encoded and hyperlinked
# takes a string and will return the same string but with email addresses encoded and hyperlinked
def emailitize text
text.gsub(/([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})/i) {|m|
mail_to(m, m.gsub("@", "[at]"), :encode=>:hex)
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment