Quantcast
Viewing all articles
Browse latest Browse all 224

Capture values using regex

Hi

I'm a Regex novice (very much learning as I go!) and I am trying to write a regex expression to capture the minimum and maximum temperature values in the string below. I'm hoping someone may be able to help e see where I have gone wrong?

class="outsideimage  m0200006341e8" title=""></td></tr><tr><th>Humidity</th><td>100%</td></tr><tr><th valign="top">Temp Min</th><td valign="top" class="mm">3.1°C</td></tr><tr><th valign="top">Temp Max</th><td valign="top" class="mm">5.7°C</td>


I have to include the m00006341e8 in the string to match as there are several other sensors that report in the overall text string and they all have a different serial number. I need to just extract the max and min values for this particular sensor. I think I've allowed for the fact that the humidity value may change

I have tried the following, but it doesn't seem to be working:

For the minimum temperature:
class="outsideimage  m0200006341e8" title=""></td></tr><tr><th>Humidity</th><td>[0-9]*\%</td></tr><tr><th valign="top">Temp Min</th><td valign="top" class="mm">([-]?[0-9]*[.]?[0-9]?)


and for the maximum temperature:

class="outsideimage  m0200006341e8" title=""></td></tr><tr><th>Humidity</th><td>[0-9]*\%</td></tr><tr><th valign="top">Temp Min</th><td valign="top" class="mm">[-]?[0-9]*[.]?[0-9]?°C</td></tr><tr><th valign="top">Temp Max</th><td valign="top" class="mm">([-]?[0-9]*[.]?[0-9]?)°C</td>

Viewing all articles
Browse latest Browse all 224

Trending Articles