Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome Programming
 PowerHome Messageboard : PowerHome Programming
Subject Topic: ph_regexsnap limit? Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
syonker
Senior Member
Senior Member
Avatar

Joined: March 06 2009
Location: United States
Online Status: Offline
Posts: 212
Posted: October 09 2010 at 21:38 | IP Logged Quote syonker

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 View syonker's Profile Search for other posts by syonker Visit syonker's Homepage
 
GadgetGuy
Super User
Super User
Avatar

Joined: June 01 2008
Location: United States
Online Status: Offline
Posts: 942
Posted: November 19 2010 at 08:12 | IP Logged Quote GadgetGuy

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 View GadgetGuy's Profile Search for other posts by GadgetGuy
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum