Created
March 29, 2015 14:37
-
-
Save xkxd/d3a4ce167e58e96e3ac1 to your computer and use it in GitHub Desktop.
removing polish characters form a string
This file contains hidden or 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
| function removePolishChars(elem) { | |
| var regExp = /ą|ć|ę|ł|ń|ó|ś|ź|ż/gi; | |
| return elem.replace(regExp, _replace); | |
| function _replace(match, offset, string) { | |
| switch (match.toLowerCase()) { | |
| case "ą": | |
| return "a"; | |
| case "ć": | |
| return "c"; | |
| case "ę": | |
| return "e"; | |
| case "ł": | |
| return "l"; | |
| case "ń": | |
| return "n"; | |
| case "ó": | |
| return "o"; | |
| case "ś": | |
| return "s"; | |
| case "ź": | |
| case "ż": | |
| return "z"; | |
| } | |
| } | |
| }; | |
| // usage var newString = removePolishChars("aćęłńśźż") -> acelnszz |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment