anij anij - 1 month ago 7
Java Question

Java regex pattern for double curly braces

I have a

String url = "/rest/devices/{{deviceId}}";


in which
{{deviceId}}
value i want to replace with some deviceId.

url.replace("{{deviceId}}", device.getId());


But it's not working.

Therefore, What to do?

Answer

I guess you are missing an assignment and result of

url.replace("{{deviceId}}", device.getId()); is ignored.

What about:

url = url.replace("{{deviceId}}", device.getId());