I have a text that has some special characters in it, for example:
Nur bei guter \U25berwachung k\o25rperliche Belastung pr\u25fen und Sie entsprechend
I have a table that maps those to german umlauts; encoded as hexadecimal unicode letters. I'm trying to replace them in the text but am failing hard...
The desired output is Ü for \U25, ö for \025 an ü for \u25.
I've tried many things, as a example
Pattern p = Pattern.compile("(\\\\[0-9A-Za-z]{3})", Pattern.MULTILINE);
Matcher matcher = p.matcher(v);
String replacement = "00FB";
while (matcher.find()) {
String match = matcher.group();
int hexToInt = Integer.parseInt(replacement, 16);
v = matcher.replaceFirst("" + hexToInt);
}
using the last line v = matcher.replaceFirst(match, "Ü"); makes my program hang forever. I also tried str.replace() methods, to no avail...
Can someone help?
Aucun commentaire:
Enregistrer un commentaire