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
Regex question
Re: Regex question
I've been trying to get this to work but it ain't happening
Pulling the file as json rather than xml, the following works in the regex tester at
(?:Device_Num_9)|(?:"LoadLevelStatus", "value": ")([0-9a-zA-Z-:]*) and returns the value - I appreciate I don't need the a-z or A-Z or - or : which can be removed, although I'm not sure what to use to get a 1 or 2 digit value - /d/d maybe? Anyway, the problem is that it doesn't work in Demopad!?
Help pleeeaase
Pulling the file as json rather than xml, the following works in the regex tester at
(?:Device_Num_9)|(?:"LoadLevelStatus", "value": ")([0-9a-zA-Z-:]*) and returns the value - I appreciate I don't need the a-z or A-Z or - or : which can be removed, although I'm not sure what to use to get a 1 or 2 digit value - /d/d maybe? Anyway, the problem is that it doesn't work in Demopad!?
Help pleeeaase
Re: Regex question
Whoops, forgot to put which regex tester I used, d'oh - http://regexlib.com/RETester.aspx
Re: Regex question
Try this... The single period gives one digit, two periods should give two.
([0-9a].)
([0-9a].)
Re: Regex question
Sussed it! With the usual help from Demopad of course I'm posting this under Lightwaverf and Veralite on the General Forum.