Last active
December 10, 2015 14:49
-
-
Save angelbotto/4449938 to your computer and use it in GitHub Desktop.
Creando el username perfecto, un pequeño metodo que ayuda a remplazar y eliminar caracteres extraños para crear un username perfecto :) :s si tiene ideas de como poder mejorarlo agradeceria enormemente :)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def perfectUsername(string) | |
string = string.tr(' ','-') | |
string = string.tr('áàäâªÁÀÂÄéèëêÉÈÊËíìïîÍÌÏÎóòöôÓÒÖÔ','aaaaaAAAAeeeeEEEEiiiiIIIIooooOOOOúùüûÚÙÛÜuuuuUUUUñÑçÇnNcC') | |
string = string.gsub(/[^0-9A-Za-z]/, '') | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@username = "ÁngelÑelis Bo##o@%☻.com_" | |
puts @username | |
#ÁngelÑelis Bo##o@%☻.com_ | |
puts perfectUsername(@username) | |
#AngelelisBoocom |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment