Java Utililty Methods String Normalize

List of utility methods to do String Normalize

Description

The list of methods to do String Normalize are organized into topic(s).

Method

StringnormalizeMatchup(final String matchup)
Returns a normalized form of the specified match-up string (which can be either a race match-up or a league match-up).
if (matchup == null)
    return null;
final String[] teams = matchup.toLowerCase().split("v");
for (int i = 0; i < teams.length; i++) {
    final char[] letters = teams[i].toCharArray();
    Arrays.sort(letters);
    teams[i] = new String(letters);
Arrays.sort(teams);
final StringBuilder sb = new StringBuilder();
for (int i = 0; i < teams.length; i++) {
    if (i > 0)
        sb.append('v');
    sb.append(teams[i]);
return sb.toString();
StringnormalizePackageNamePart(String name)
normalize Package Name Part
StringBuffer sname = new StringBuffer(name.toLowerCase());
for (int i = 0; i < sname.length(); i++) {
    sname.setCharAt(i, Character.toLowerCase(sname.charAt(i)));
for (int i = 0; i < sname.length(); i++) {
    if (!Character.isJavaIdentifierPart(sname.charAt(i))) {
        sname.setCharAt(i, '_');
if (isJavaKeyword(sname.toString())) {
    sname.insert(0, '_');
if (!Character.isJavaIdentifierStart(sname.charAt(0))) {
    sname.insert(0, '_');
return sname.toString();
StringnormalizeRepositoryName(String input)
normalize Repository Name
if (input.startsWith(".") || input.startsWith("-"))
    input = normalizeRepositoryName(input.substring(1));
if (input.endsWith(".") || input.endsWith("-"))
    input = normalizeRepositoryName(input.substring(0, input.length() - 1));
return repoP3.matcher(repoP2
        .matcher(repoP1.matcher(Normalizer.normalize(input, Normalizer.Form.NFD)).replaceAll(EMPTY_STRING))
        .replaceAll(EMPTY_STRING)).replaceAll(EMPTY_STRING);
StringnormalizeSearchString(String src)
normalize Search String
return unaccent(src.toLowerCase().replace("-", " "));
StringnormalizeString(String input)
normalize String
return Normalizer.normalize(input, Normalizer.Form.NFD).replaceAll("\\p{M}", "").replaceAll("\\W+", " ")
        .toLowerCase().trim();
StringnormalizeString(String str)
normalize String
return NORMAL_PATTERN.matcher(Normalizer.normalize(str.toLowerCase(), Normalizer.Form.NFD)).replaceAll("")
        .replaceAll("[^A-Za-z0-9]", "");
StringnormalizeString(String token)
normalize String
char[] charArray = token.toCharArray();
char[] toReturn = new char[charArray.length];
int index = 0;
for (int i = 0; i < charArray.length; i++) {
    char x = charArray[i];
    if (x < CHARACTER_REPLACE_MAPPING.length) {
        if (CHARACTER_REPLACE_MAPPING[x] > 0) {
            toReturn[index++] = CHARACTER_REPLACE_MAPPING[x];
...
StringnormalizeSuffix(String suffix)
normalize a suffix for shelf list sorting by changing all digit substrings to a constant length (left padding with zeros).
if (suffix != null && suffix.length() > 0) {
    StringBuilder resultBuf = new StringBuilder(suffix.length());
    String[] digitStrs = suffix.split("[\\D]+");
    int len = digitStrs.length;
    if (digitStrs != null && len != 0) {
        int s = 0;
        for (int d = 0; d < len; d++) {
            String digitStr = digitStrs[d];
...
ListnormalizeTestAndSplit(String text)
normalize Test And Split
return Arrays.asList(text.split("(\\.|;|!|\\?|,)+"));
StringnormalizeTibetan(String s)
normalize Tibetan
String res = Normalizer.normalize(s, Normalizer.Form.NFD);
res = res.replace("\u0F79", "\u0FB3\u0F71\u0F80");
res = res.replace("\u0F77", "\u0FB2\u0F71\u0F80");
res = res.replace("\u0F81", "\u0F71\u0F80");
res = res.replace("\u0F75", "\u0F71\u0F74");
res = res.replace("\u0F73", "\u0F71\u0F72");
return res;