Skip to content

Instantly share code, notes, and snippets.

@xkxd
Created March 29, 2015 14:37
Show Gist options
  • Select an option

  • Save xkxd/d3a4ce167e58e96e3ac1 to your computer and use it in GitHub Desktop.

Select an option

Save xkxd/d3a4ce167e58e96e3ac1 to your computer and use it in GitHub Desktop.
removing polish characters form a string
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