GestionDesInscriptions/src/outils/supprimeCaracatresSpeciaux.java

23 lines
722 B
Java
Raw Normal View History

2023-07-09 21:11:39 +02:00
package outils;
2023-06-22 13:27:37 +02:00
import java.text.Normalizer;
public class supprimeCaracatresSpeciaux {
public static String TousLesCaracatresSpeciaux(String str) {
2023-07-13 17:29:33 +02:00
2023-06-22 13:27:37 +02:00
// Supprimer les accents
String normalizedStr = Normalizer.normalize(str, Normalizer.Form.NFD);
String accentRemovedStr = normalizedStr.replaceAll("\\p{InCombiningDiacriticalMarks}+", "");
// Supprimer les caractères spéciaux
String specialCharRemovedStr = accentRemovedStr.replaceAll("[^a-zA-Z0-9@\\_\\-\\. ]", "");
//Replace tous les espaces par des underscore
String replaceSpace = specialCharRemovedStr.replaceAll(" ","_");
return replaceSpace;
}
}