简体   繁体   中英

How to remove acute accents from string in java?

I know about this

public static String stripAccents(String s) {
    s = Normalizer.normalize(s, Normalizer.Form.NFD);
    s = s.replaceAll("[\\p{InCombiningDiacriticalMarks}]", "");
    return s;
}

but it works not the way I want. It changes the sense of text

stripAccents("йод,ëлка,wäre") //иод,елка,ware

I want to delete only acute accents

stripAccents("café") //cafe

I know about this

public static String stripAccents(String s) {
    s = Normalizer.normalize(s, Normalizer.Form.NFD);
    s = s.replaceAll("[\\p{InCombiningDiacriticalMarks}]", "");
    return s;
}

but it works not the way I want. It changes the sense of text

stripAccents("йод,ëлка,wäre") //иод,елка,ware

I want to delete only acute accents

stripAccents("café") //cafe

I know about this

public static String stripAccents(String s) {
    s = Normalizer.normalize(s, Normalizer.Form.NFD);
    s = s.replaceAll("[\\p{InCombiningDiacriticalMarks}]", "");
    return s;
}

but it works not the way I want. It changes the sense of text

stripAccents("йод,ëлка,wäre") //иод,елка,ware

I want to delete only acute accents

stripAccents("café") //cafe

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM