I have a string surname.
I want to replace special Bulgarian. Polish Characters with an English standard replacement.
For example surname = "Tuğba Delioğlu"
Final Output string should be: tugbadelioglu
To implement this I have just done a series of string.replaceAll as follows:-
surname = surname.replaceAll("ı", "i");
surname = surname.replaceAll("ł", "l");
surname = surname.replaceAll("Ł", "l");
surname = surname.replaceAll("ń", "n");
surname = surname.replaceAll("ğ", "g");
surname = surname .replaceAll("\\p{InCombiningDiacriticalMarks}+", ""); // this will remove diacritics
String newSurname = surname.replaceAll("[^a-zA-Z]",""); // remove non A-Z characters
surname = surname.replaceAll("\\s","").toLowerCase(); // remove spaces and make lowercase
Is there a more efficient way to do this i.e. have an array with:- Character to Replace Character to Replace with
then loop through the string and replace each matching character with its representation from the array?
This will be fairly high volume, so looking for the most efficient way to do it.