REGEX help


I’m running the MQTT binding in OH4 and I am trying to make use of the REGEX binding as well :slight_smile:
I have following stated under the “Incoming Value Transformations” in the MQTT generic item:


But why is this not working when I am trying to transform an incoming MQTT string and capture 5.5 from the the paramter 1-0:31.7.0 in the string below?


Side note, I am not sure if the “\n” and “\r” are being processed by the REGEX transformation. If I look at the item in the UI there are no “\n” or “\r”, but if I check the item via the REST API it is shown as above. But I have tried my REGEX statement with and without the extra characters and still get the same result.


Help appreciated.

\r\n means there’s a line break in the text, which is a bit tricky to handle in regex, since it sometimes only handles one line at a time. Not sure how the regex transformation in OH handles it though. But I would suggest to simplify the expression so you get some output working, and then add more to it if needed. Especially leave out the look-ahead/behind, they often complicate things more than they help.

Try something like this for example:

1 Like

Simpler is better :slight_smile:
I’ve tried to google a solution to removing the first part of the output I get with your REGEX?

The output I get is:


and I need to remove:


I only want the 05.5 value.

swe Tack för hjälpen :slight_smile: /swe


1 Like

Thank you!