Boucle sur classe Pattern
Bonjour,
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
private static final Pattern PATTERN = Pattern.compile("[éôè]");
...
while (_matcher.find()) {
str = replaceAccent(str);
}
...
private static final String replaceAccent(String str) {
if (_matcher.group().equals("é")) {
str = str.replace("é", "e");
} else if (_matcher.group().equals("ô")) {
str = str.replace("ô", "o");
} else {
str = str.replace("è", "e");
}
return str ;
} |
Je ne trouve pas ma méthode très replaceAccent performante.
Je partais pour faire une mini hashmap map.put("é"); map.put("ô); ... avec un while pour remplacer mes if, mais je trouve qu'elle fait doublons avec le Pattern.
Voyez-vous une autre solution