[ECMA] .replaceAll/RegEx Problem

I’m trying to use .replaceALL on a JSON-String variable. It does work in DSL but in fails to do so in ECMA.
I want to replace all "pid":XXX (with XXX any number of digits) with "pid": + MyVariable.

myJSONString.replaceAll('"pid":([0-9]+)', '"pid":' + openHAB_PID);

Checking the String afterwards shows it unchanged.
What am I missing??

The difference between the string you say you want to replace ( “pid”: XXX ) and the expression you wrote is that the expression does not have a space in.
Not sure if that is just a typo.

1 Like

Thanks for looking, but that was just a typo.
I changed the OP.

Stupid.Me!! Did not assing the changed string to a variable.
myJSONString = myJSONString.replaceAll('"pid":([0-9]+)', '"pid":' + openHAB_PID);

1 Like