I have the folowing string for example:
O > O §o TEXT §r §o TEXT §r
I need to replace all "§r" with "§r§a" only after ">" character.
It should be
O > O §o TEXT §r§a §o TEXT §r§a
as the result.
I tried >*(\§r) regex but it ignores >.
May You point on my error?
The easiest way to do this would be to split it into two strings first and then run a
replace. That is, you could take
int index = inputString.indexOf('>') + 1; String first = inputString.subString(0, index); String second = inputString.subString(index); String finalString = first + second.replace("§r", "§r§a");
Doing this with a pure regular expression would be difficult.