I have this sentence:
"I have 3 bananas at 20:00 o'clock".
I need to replace the number in the string so it will include unicode:
"I have \u200e3\u200e bananas at \u200e20\u200e:\u200e00\u200e o'clock"
I have this sentence:
"I have 3 bananas at 20:00 o'clock".
I need to replace the number in the string so it will include unicode:
"I have \u200e3\u200e bananas at \u200e20\u200e:\u200e00\u200e o'clock"
The replacement in your example can be done using String.replaceAll():
String string = "I have 3 bananas at 20:00 o'clock";
string = string.replaceAll("\\d+", "\\\\u200e$0\\\\u200e");
System.out.println(string);
prints
I have \u200e3\u200e bananas at \u200e20\u200e:\u200e00\u200e o'clock