Regex question
Posted: Sat Nov 23, 2013 7:00 pm
I'm struggling with Regex
The following regex works in Demopad but not in http://www.regextester.com/ or other testers I found, in fact, there even seems to be disparity between different testers
<state id=".*" service="urn:upnp-org:serviceId:Dimming1" variable="LoadLevelStatus" value="(.*)"></state> with </state> as the terminator
I don't know much about regex so the answer might be obvious to someone. Does anyone know why this is? Also, I want to find 2 terms in one xml file but can't work out how to do this - despite a great guide at http://www.silverstones.com/thebat/Regex.html; specifically, I want to send the value of LoadLevelStatus to a number providing Device_Num_9 is also present;
<root LoadTime="1385139141" DataVersion="139142321" UserData_DataVersion="139141022" TimeStamp="1385229600" ZWaveStatus="1" LocalTime="2013-11-23 18:00:00 N">
<Device_Num_9 status="-1">
<states>
<state id="135" service="urn:upnp-org:serviceId:SwitchPower1" variable="Status" value="1"/>
<state id="136" service="urn:upnp-org:serviceId:Dimming1" variable="LoadLevelStatus" value="10"/>
<state id="137" service="urn:micasaverde-com:serviceId:HaDevice1" variable="Configured" value="0"/>
<state id="138" service="upnp-rfxcom-com:serviceId:rfxtrx1" variable="Assocation" value=""/>
<state id="139" service="upnp-rfxcom-com:serviceId:rfxtrx1" variable="KopplaProgrammed" value="1"/>
</states>
<Jobs/>
<tooltip display="0"/>
</Device_Num_9>
</root>
Any help would be much appreciated
The following regex works in Demopad but not in http://www.regextester.com/ or other testers I found, in fact, there even seems to be disparity between different testers
<state id=".*" service="urn:upnp-org:serviceId:Dimming1" variable="LoadLevelStatus" value="(.*)"></state> with </state> as the terminator
I don't know much about regex so the answer might be obvious to someone. Does anyone know why this is? Also, I want to find 2 terms in one xml file but can't work out how to do this - despite a great guide at http://www.silverstones.com/thebat/Regex.html; specifically, I want to send the value of LoadLevelStatus to a number providing Device_Num_9 is also present;
<root LoadTime="1385139141" DataVersion="139142321" UserData_DataVersion="139141022" TimeStamp="1385229600" ZWaveStatus="1" LocalTime="2013-11-23 18:00:00 N">
<Device_Num_9 status="-1">
<states>
<state id="135" service="urn:upnp-org:serviceId:SwitchPower1" variable="Status" value="1"/>
<state id="136" service="urn:upnp-org:serviceId:Dimming1" variable="LoadLevelStatus" value="10"/>
<state id="137" service="urn:micasaverde-com:serviceId:HaDevice1" variable="Configured" value="0"/>
<state id="138" service="upnp-rfxcom-com:serviceId:rfxtrx1" variable="Assocation" value=""/>
<state id="139" service="upnp-rfxcom-com:serviceId:rfxtrx1" variable="KopplaProgrammed" value="1"/>
</states>
<Jobs/>
<tooltip display="0"/>
</Device_Num_9>
</root>
Any help would be much appreciated