If you are looking for replace the German Umlaute with cleverly respecting the case, use this (opensource, happy to share, all by me) in JavaScript:
let umlautMap = {
'\u00dc': 'UE',
'\u00c4': 'AE',
'\u00d6': 'OE',
'\u00fc': 'ue',
'\u00e4': 'ae',
'\u00f6': 'oe',
'\u00df': 'ss',
}
function replaceUmlaute(str) {
return str
.replace(/[\u00dc|\u00c4|\u00d6][a-z]/g, (a) => {
var big = umlautMap[a.slice(0, 1)];
return big.charAt(0) + big.charAt(1).toLowerCase() + a.slice(1);
})
.replace(new RegExp('['+Object.keys(umlautMap).join('|')+']',"g"),
(a) => umlautMap[a]
);
}
It will:
- Übung -> Uebung
- ÜBUNG -> UEBUNG
- üben -> ueben
- einüben -> einueben
- EINÜBEN -> EINUEBEN
- and the same for Ä, Ö
- and simple ß -> ss