Suppose I have a string like this:
"abc%\%%%%"
I want to replace multiple %%% with only one %. I tried something like
String st = "abc%\%%%%".replaceAll("(%)\\1+", "$1");
But that would also turn "\%%" into "\%", which is not what I want. In other words, I want to replace multiple % but leave alone those preceded by a backslash.
What regex should I use? Thanks