Skip to content

Instantly share code, notes, and snippets.

@huantt
Created December 27, 2018 07:19
Show Gist options
  • Save huantt/8dcb9537bf37a44163c50ebe8fb08b4a to your computer and use it in GitHub Desktop.
Save huantt/8dcb9537bf37a44163c50ebe8fb08b4a to your computer and use it in GitHub Desktop.
package x10adflex.growthhacking.common
import java.text.Normalizer
import java.util.regex.Pattern
/**
* @author huantt on 2018-12-27
*/
class AccentRemover {
static String remove(String str) {
try {
String temp = Normalizer.normalize(str, Normalizer.Form.NFD)
Pattern pattern = Pattern.compile("\\p{InCombiningDiacriticalMarks}+")
return pattern.matcher(temp).replaceAll("")
} catch (Exception ex) {
ex.printStackTrace()
}
return ""
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment