Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome Programming
 PowerHome Messageboard : PowerHome Programming
Subject Topic: RegEx Trouble Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: June 28 2008 at 09:02 | IP Logged Quote TonyNo

Having troubles here.

Code:
ph_regexdiff('<description><![CDATA[~128~129~255<description><![CDATA[~128~129~255<description><![CDATA[~128~129~255<description><![CDATA[~128~129',']]></',"{RSS WX}", 1, 2)

I've tried escaping the brackets with no change.

Here is a chunk of the string being searched...

Code:
<description><![CDATA[
     Today - Partly sunny. Scattered showers and thunderstorms in the afternoon. Highs in the upper 70s. West winds 10 to 15 mph. Chance of precipitation 50 percent.
      ]]></description

Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
BeachBum
Super User
Super User
Avatar

Joined: April 11 2007
Location: United States
Online Status: Offline
Posts: 1880
Posted: June 28 2008 at 20:33 | IP Logged Quote BeachBum

Tony, I played with this but don’t understand why the multiple <description><![CDATA[~128~129~255 in the first expression. I was able to get something, but not what you probably are looking for, by putting brackets around the first expression without the CR + LF.

ph_regexdiff('[<description><![CDATA',']]></',"{RSS WX}", 1, 2)

The bracket seems to be the problem.


__________________
Pete - X10 Oldie
Back to Top View BeachBum's Profile Search for other posts by BeachBum
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: June 29 2008 at 00:14 | IP Logged Quote TonyNo

The multiples are to get to the data I'm looking for, four description tags down. This is an RSS page I'm parsing. I can't recall if that worked before, or if the brackets are new. Thanks for checking.
Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
jbbtex
Senior Member
Senior Member


Joined: February 15 2007
Location: United States
Online Status: Offline
Posts: 181
Posted: June 29 2008 at 11:22 | IP Logged Quote jbbtex

I'm with Pete on the brackets, but I also found that the < before ![CDATA probably needs to be escaped as well.

I used <description>~255 and was able to get the fourth match. However, <description><~255 returns nothing.


__________________
Brady

"Never tell people how to do things. Tell them what to do and they will surprise you with their ingenuity." - Gen. George S. Patton
Back to Top View jbbtex's Profile Search for other posts by jbbtex
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: June 29 2008 at 14:11 | IP Logged Quote TonyNo

Interesting! Thanks Brady.
Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: June 30 2008 at 11:33 | IP Logged Quote dhoward

Tony,

Try this:
Code:
ph_regexdiff1('<description><!' + '\[' + 'CDATA' + '\[','\]\]></',ph_getglobal_s("RSS WX"),1,4,0,0,0)


The ph_regexdiff1 allows you specify the "occurrence" which is the 4th one in your sample. This way you don't have to do the multiple repeats. I also broke out the '[' so there is no way it can be interpreted as a system variable during variable substitution. I also escaped the brackets as that is necessary as well for the regex to function. I used the ph_getglobal_s instead of variable substitution since it's possible that the substitution could be large and could contain embedded double quotes which would throw the function evaluation off. Last, I didnt do the cr/lf substitution since this will always be slower and is better if it can be avoided. This means that the result will contain the cr/lf which you probably dont want but a simple wrapping of the result in a ph_replaceall(...,"~r~n","") will take care of this.

Let me know how this works for you.

Dave.
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: June 30 2008 at 13:41 | IP Logged Quote TonyNo

Thanks for the occurrence tip!

Still no go, though.
Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
jbbtex
Senior Member
Senior Member


Joined: February 15 2007
Location: United States
Online Status: Offline
Posts: 181
Posted: July 01 2008 at 17:44 | IP Logged Quote jbbtex

Code:
ph_regexdiff1('CDATA' + '\[','\]',ph_getsystemvar("LOCAL1"),1,4,0,0,0)


I figured you were using WU RSS feed and I had some free time. I used a local variable just so I didn't have to create a GV.

This returns just the text of the forecast, but there is a CR/LF and TAB at the beginning and a CR/LF at the end.

If I tried to add anything before CDATA or after the first square bracket following the forecast, it returned nothing.

Edited by jbbtex - July 01 2008 at 17:46


__________________
Brady

"Never tell people how to do things. Tell them what to do and they will surprise you with their ingenuity." - Gen. George S. Patton
Back to Top View jbbtex's Profile Search for other posts by jbbtex
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: July 01 2008 at 19:50 | IP Logged Quote TonyNo

Interesting. This doesn't even work for me. Are you running the alpha?
Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
jbbtex
Senior Member
Senior Member


Joined: February 15 2007
Location: United States
Online Status: Offline
Posts: 181
Posted: July 01 2008 at 20:12 | IP Logged Quote jbbtex

Nope.

__________________
Brady

"Never tell people how to do things. Tell them what to do and they will surprise you with their ingenuity." - Gen. George S. Patton
Back to Top View jbbtex's Profile Search for other posts by jbbtex
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: July 01 2008 at 23:44 | IP Logged Quote TonyNo

Ah! Maybe a clue!
Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: July 25 2008 at 12:46 | IP Logged Quote TonyNo

Loaded up the latest alpha and I'm making progress. This is working now...

Code:
ph_regexdiff1('<description><!' + '\[' + 'CDATA' + '\[','\]\]></',"[LOCAL1]",1,3,0,0,0)


The third one works, the fourth doesn't.
Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo'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