Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome Programming
 PowerHome Messageboard : PowerHome Programming
Subject Topic: ph_regexdiff1 help 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: August 02 2014 at 13:02 | IP Logged Quote syonker

Hi Gang,

Rewriting my weather macro to take in a number of other
variables for irrigation control and I am running into a
user-oriented (ID10-T error here for sure)...also known
as a problem in the "Keyboard-to-Chair" interface. I
mean I am *really* stupid on this one.

Alright, here goes...I am totally not doing this right
and I don't understand things like the (I assume)
deprecated "~255" command, or the additional flags, that
are on the new ph_regexdiff1() command...

I am trying (for example) to extract "Wind Speed" from
this slice of HTML...



...by using the following function...

ph_regexdiff1('</b> at<span class="nowrap"><br>',
"</b> mph</span>","[LOCAL1]",1,1,1,0,0)

...and of *course* I am getting nothing out of it.

Haven't been able to glean from the help files or the
forum just how this is done. Is there someone out there
well versed in this that could provide a comprehensive
explanation of how this parsing function works?

Thanks in advance for any assistance.

-S

Edited by syonker - August 02 2014 at 13:06


__________________
"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
 
syonker
Senior Member
Senior Member
Avatar

Joined: March 06 2009
Location: United States
Online Status: Offline
Posts: 212
Posted: August 02 2014 at 13:04 | IP Logged Quote syonker

Here is the formula:

[/IMG]

__________________
"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
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: August 04 2014 at 07:11 | IP Logged Quote TonyNo

Maybe this bit is the key...

This function will also not perform a regular expression search that spans multiple lines. If the data to search contains carraige returns or line feeds, the entire matching search data for the regular expression must exist within a single line. If your regular expression must span across a line, then add 2 to the flags to have CR's and LF's temporarily converted. CR will be converted to ASCII 128 and LF will be converted to ASCII 129. If you convert CF/LF then you can include them in your search with PowerHome escape characters ~128 and ~129 respectively.
Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
syonker
Senior Member
Senior Member
Avatar

Joined: March 06 2009
Location: United States
Online Status: Offline
Posts: 212
Posted: August 04 2014 at 12:46 | IP Logged Quote syonker

Outstanding information that! Thanks Sir!

__________________
"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
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: August 04 2014 at 20:19 | IP Logged Quote dhoward

S,

You may want to look into using the new ph_regexdiff2 function. This uses the Visual Basic regular expression engine vs the Scintilla regular expression engine that ph_regexdiff1 uses. The best site I have found for documentation on the VB regex is here: http://www.regular-expressions.info/vb.html

Another alternative would be to use the new ph_urlscraper plugin to pull in the weather data and scrape the entries (it uses the VB regex engine as well). Using the plugin will be more efficient as the data will be pulled in asynchronously in the background.

If you want to use ph_regexdiff1, I would change the formula to:

ph_regexdiff1('<td>Wind</td>~255<b>~255< ;b>',
"</b>","[LOCAL1]",1,1,1,0,0)

The formula first searches for the Wind section. After finding that, it then searches for the first <b> tag. After finding that, it searches for the next (second) bold tag and retrieves that value.

Hope this helps,

Dave.
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
syonker
Senior Member
Senior Member
Avatar

Joined: March 06 2009
Location: United States
Online Status: Offline
Posts: 212
Posted: August 06 2014 at 07:29 | IP Logged Quote syonker

Totally gonna check out that plugin, Dave. Coupled with the Weather Underground API, it might be a real double-win in this particular problem space.

Tony, I forgot to mention that your advice was spot-on and totally worked. Thanks a TON for that!

Thanks for the heads up!

-S

Edited by syonker - August 06 2014 at 07:30


__________________
"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
 

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