Last active
March 17, 2017 12:18
-
-
Save michalbcz/7320173 to your computer and use it in GitHub Desktop.
replacing characters with diacritic (national characters) with variant without diacritic eg. replace Á to A..etc.
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
public final class StringUtils { | |
private StringUtils() { /* cannot be instantiated */ } | |
/** | |
* <b>WORKS ONLY IN JAVA 1.6 AND ABOVE !!!</b> | |
* | |
* @param textWithDiacritic | |
*/ | |
public static String removeDiacritics(String textWithDiacritic) { | |
String decomposed = java.text.Normalizer.normalize(textWithDiacritic, Normalizer.Form.NFD); | |
return decomposed.replaceAll("\\\\p{InCombiningDiacriticalMarks}+", ""); | |
} | |
} |
javascript verze
const str = "Crème Brulée" str.normalize('NFD').replace(/[\u0300-\u036f]/g, "")
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
copy paste from http://blog.softeu.cz/odhackovani/