Skip to content
Advertisement

Get temperature from string with regex

I could really use som help getting the temperature value out of this string:

“type=sensor protocol=fineoffset model=temperaturehumidity id=135 temperature=26.5 humidity=49 time=2014-07-01 21:03:24 age=29”

I figured that you can write a regex that takes the value between termperature= and s to get the numeric value. I’ve tried this but I couldnt get the hang of it.

Advertisement

Answer

Try it with this small snippet

temperatures*=s*K(?<temperature>d+(?:.d+))

Regular expression visualization

Debuggex Demo

It will give you in the response array the key temperature with your wanted value

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement