Skip to content

Instantly share code, notes, and snippets.

@klzns
Created April 22, 2013 14:41
Show Gist options
  • Save klzns/5435593 to your computer and use it in GitHub Desktop.
Save klzns/5435593 to your computer and use it in GitHub Desktop.
Function that removes all accentuation from a string (based on Underscore String)
plainChars = (str) ->
if not str? then return throw(new Error("plainChars needs a param"))
specialChars = "ąàáäâãåæćęèéëêìíïîłńòóöôõøśùúüûñçżź"
plain = "aaaaaaaaceeeeeiiiilnoooooosuuuunczz"
regex = new RegExp '[' + specialChars + ']', 'g'
str += ""
str.replace regex, (char) -> plain.charAt (specialChars.indexOf char)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment