Serial Port Extract Value via REGEX Issue

  • Platform information:
    • Hardware: SERVER
    • OS: WINDOWS
    • openHAB version: openHAB 4.1.2

For the love of god I cannot get a certain status value out of a string sent via serial port.
I created a string item with REGEX (.*) to recieve the full string:
Reed1=OPEN; Reed2=OPEN; Reed3=OPEN; Reed4=OPEN; Reed5=OPEN; Reed6=OPEN; Reed7=OPEN; Reed8=OPEN; Reed9=OPEN; Reed10=CLOSED;

Now I want to build a channel for each Reed sensor value, i.e. for Reed sensor 3: Reed3.
My REGEX code: .*Reed3=(.*);.*

Reads:
OPEN; Reed4=OPEN; Reed5=OPEN; Reed6=OPEN; Reed7=OPEN; Reed8=OPEN; Reed9=OPEN; Reed10=CLOSED

What is the problem?

There are several regex sites out there where you can try your regex.

In this case:

.*Reed3=(.*);.*

Change it to:

.*Reed3=(.*?);.*

Changes the capture group from greedy (as many times as possible) to lazy (one time). That could do the trick. At least works on the regex site I used :wink:

Thanks! Worked.