Rule - Transform with REGEX

Hi, everybody.

I wanted to extract the value before the point in my values.

I used this val, but when I put “25.0” (without quotes) I extract “25.” (without quotes), and I don’t want the dot.

val mqttPayloadhomekit = transform("REGEX", "^(.+?).", Aireacondicionado_setpointhomekitp.state.toString)

In REGEX certain characters have meaning. . is one of those characters and it means “any character”). + means one or more of the previous match and ? means zero or one of the previous match and ^ means the beginning of the line. So in English this expression says “At the start of the line, give me any character one or more times zero or more times followed by any character.” That doesn’t really mean anything at all really.

So what about (\d+)\..*. In English that says “give me (parens define what you want returned) one or more digits (\d+) followed by a literal “.” (\.) and anything else that might occur after the dot (.*).”

Thanks! With (\\d+)\\..* work perfectly

val mqttPayloadhomekit = transform("REGEX", "(\\d+)\\..*" , Aireacondicionado_setpointhomekitp.state.toString)