Java String Accent removeAccents(final String value)

Here you can find the source of removeAccents(final String value)

Description

Remove accents from any character i.e.

License

Open Source License

Parameter

Parameter Description
value input value

Return

string value

Declaration

public static String removeAccents(final String value) 

Method Source Code


//package com.java2s;
import java.text.Normalizer;
import java.util.regex.Pattern;

public class Main {
    /** Empty String constant '' */
    public final static String STRING_EMPTY = "";
    /** regular expression used to match characters with accents */
    private final static Pattern PATTERN_ACCENT_CHARS = Pattern.compile("\\p{InCombiningDiacriticalMarks}+");

    /**/*  w ww. j  av  a2  s.  com*/
     * Remove accents from any character i.e. remove diacritical marks
     * @param value input value
     * @return string value
     */
    public static String removeAccents(final String value) {
        // Remove accent from characters (if any) (Java 1.6)
        final String normalized = Normalizer.normalize(value, Normalizer.Form.NFD);

        return PATTERN_ACCENT_CHARS.matcher(normalized).replaceAll(STRING_EMPTY);
    }
}

Related

  1. removeAccent(String s)
  2. removeAccent(String s)
  3. removeAccent(String strIn)
  4. removeAccents(final String s)
  5. removeAccents(final String value)
  6. removeAccents(String input)
  7. removeAccents(String s)
  8. removeAccents(String str)
  9. removeAccents(String text)