Skip to content

Instantly share code, notes, and snippets.

@madrobby
Created December 21, 2014 18:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save madrobby/27b537ab0344c827daf8 to your computer and use it in GitHub Desktop.
Save madrobby/27b537ab0344c827daf8 to your computer and use it in GitHub Desktop.
letters = ""
letters << user.first_name[0,1] if user.first_name.size > 1 && 'A'..'Z'.include?(user.first_name[0,1].upcase)
letters << user.last_name[0,1] if user.last_name.size > 1 && 'A'..'Z'.include?(user.last_name[0,1].upcase)
@stefanoc
Copy link

letters = "#{first_name[0]}#{last_name[0]}".gsub(/[^A-Z]/, '')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment