Java String Normalize normalizeSearchString(String src)

Here you can find the source of normalizeSearchString(String src)

Description

normalize Search String

License

Open Source License

Declaration

public static String normalizeSearchString(String src) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.text.Normalizer;

import java.util.regex.Pattern;

public class Main {
    public static String normalizeSearchString(String src) {
        return unaccent(src.toLowerCase().replace("-", " "));
    }/*from  w w  w . j a v  a2s. com*/

    public static String unaccent(final String src) {

        final String temp = Normalizer.normalize(src, Normalizer.Form.NFKD);
        final Pattern pattern = Pattern.compile("\\p{InCombiningDiacriticalMarks}+");
        return pattern.matcher(temp).replaceAll("");

    }

    public static String normalize(final String src) {
        return Normalizer.normalize(src, Normalizer.Form.NFD).replaceAll("[^\\p{ASCII}]", "").replaceAll("[\\s/]",
                "_");
    }
}

Related

  1. normalizeFieldNameOrPath(final String nameOrPath)
  2. normalizeIndex(String input, String[] indexList)
  3. normalizeMatchup(final String matchup)
  4. normalizePackageNamePart(String name)
  5. normalizeRepositoryName(String input)
  6. normalizeString(String input)
  7. normalizeString(String str)
  8. normalizeString(String token)
  9. normalizeSuffix(String suffix)