Author |
|
syonker Senior Member
Joined: March 06 2009 Location: United States
Online Status: Offline Posts: 212
|
Posted: October 09 2010 at 21:38 | IP Logged
|
|
|
Hi Gang,
Ok consider this comma-delimited line of data:
1.01,1999,1,1,5,27,39,4,9,104,24,0,87.1,0.1,24.51,0.11,0.22, 0.33,3,4.4,5,6.6,7,8.8,9,10.10,11.0,12,8.9,84.0,-2.2,13.0,14 .000,15.0,2.9,16.00,17.0,18.0,0.0,0.00,0.00
I am attempting to use ph_regexsnap to try to get the 29th value in the string (which in a Virtual Weather Station would represent the "Indoor Temperature" - a useful piece of data).
Here is the function: ph_regexsnap("[0-9\.\-]*,[0-9\.\-]*,[0-9\.\-]*,[0-9\.\-]*,[0-9\.\-]*,[0-9\.\-]*,[0-9\.\-]*,[0-9\.\-]*,[0-9\.\-]*,[0-9\.\-]*,[0-9\.\-]*,[0-9\.\-]*,[0-9\.\-]*,[0-9\.\-]*,[0-9\.\-]*,[0-9\.\-]*,[0-9\.\-]*,[0-9\.\-]*,[0-9\.\-]*,[0-9\.\-]*,[0-9\.\-]*,[0-9\.\-]*,[0-9\.\-]*,[0-9\.\-]*,[0-9\.\-]*,[0-9\.\-]*,[0-9\.\-]*,[0-9\.\-]*,[0-9\.\-],\([0-9\.\-]*\),","[LOCAL1]",1,0)
Interestingly, when I add the 29th parse string, it returns a blank; however, the 28th returns 8.9.
The number I am *trying* to get out of this string is "84.0".
Thoughts...?
-S
__________________ "I will consider myself having succeeded when my house becomes sentient and attempts to kill me."
><(((º>`·.¸¸.·´¯`·.¸><(((º>¸.
·´¯`·.¸. , . ><(((º>`·.¸¸.·´¯`·.¸><(((º>
|
Back to Top |
|
|
GadgetGuy Super User
Joined: June 01 2008 Location: United States
Online Status: Offline Posts: 942
|
Posted: November 19 2010 at 08:12 | IP Logged
|
|
|
Syonker -
I'm by far not an expert on these string searches yet (but working hard on it). Over the last few days I have discovered incredible string capability I never realized existed in PH! I have been writing my own parsing macros for over a year to do much of the same. I'm now going back and simplifying all that work!
With regard to your issue above, I'm thinking that simplification is the key. Rather than creating such a complex search string, try using the
ph_regexdiff1 ( pat1, pat2, data, start, occ, flags, localstart, locallength )
function (see the PH Help file for info rather than repeat it all here).
Using the "occ" (occurences) parameter you could then skip over the first 27 commas and only grab the data in the 28th slot.
I have done something like that to extract info from a CSV file.
__________________ Ken B - Live every day like it's your last. Eventually, you'll get it right!
|
Back to Top |
|
|
|
|