un Accent - Java java.lang

Java examples for java.lang:String UTF

Description

un Accent

Demo Code


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

public class Main {
    public static String unAccent(String s) {
        ///*w w  w  .j  a  v a 2s .  c o  m*/
        // JDK1.5
        //   use sun.text.Normalizer.normalize(s, Normalizer.DECOMP, 0);
        //
        String temp = Normalizer.normalize(s, Normalizer.Form.NFD);
        Pattern pattern = Pattern
                .compile("\\p{InCombiningDiacriticalMarks}+");
        return pattern.matcher(temp).replaceAll("");
    }
}

Related Tutorials