In Java, I need to change this:
myid=460\u0026url=http%3A%2F%2Fr20-xxxx
...to this:
myid=460&url=http%3A%2F%2Fr20-xxxx
Here's what I've tried:
String map = "myid=460\\u0026url=http%3A%2F%2Fr20-xxxx";
p = Pattern.compile("\\u0026");
m = p.matcher(map);
if (m.find()) {
String ret = m.replaceAll("&");
}
...but it cannot find the \u0026.
If you must use a regex, then you must escape the backslash that is in the Java string. Then you must escape both backslashes for regex interpretation. Try
p = Pattern.compile("\\\\u0026");
But a simple replace should suffice (it doesn't use regex), with only one iteration of escape the backslash, for Java:
ret = map.replace("\\u0026", "&");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With