| Author | 
         | 
         
      
        
         
         TonyNo Moderator Group 
          
  
  Joined: December 05 2001 Location: United States
 Online Status: Offline Posts: 2889
          | 
        
         
          
           | Posted: June 28 2008 at 09:02 | IP Logged
		     | 
                    
            		  
           | 
           
          
           
  | 
           
          
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 | 
         
          
          
         | 
       
       
       
        |   | 
      
        
         
         BeachBum Super User 
          
  
  Joined: April 11 2007 Location: United States
 Online Status: Offline Posts: 1880
          | 
        
         
          
           | Posted: June 28 2008 at 20:33 | IP Logged
		     | 
                    
            		  
           | 
           
          
           
  | 
           
          
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 | 
         
          
         | 
       
       
       
        |   | 
      
        
         
         TonyNo Moderator Group 
          
  
  Joined: December 05 2001 Location: United States
 Online Status: Offline Posts: 2889
          | 
        
         
          
           | Posted: June 29 2008 at 00:14 | IP Logged
		     | 
                    
            		  
           | 
           
          
           
  | 
           
          
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 | 
         
          
          
         | 
       
       
       
        |   | 
      
        
         
         jbbtex Senior Member 
          
 
  Joined: February 15 2007 Location: United States
 Online Status: Offline Posts: 181
          | 
        
         
          
           | Posted: June 29 2008 at 11:22 | IP Logged
		     | 
                    
            		  
           | 
           
          
           
  | 
           
          
I'm with Pete on the brackets, but I also found that the < before  
  
  Joined: December 05 2001 Location: United States
 Online Status: Offline Posts: 2889
          | 
        
         
          
           | Posted: June 29 2008 at 14:11 | IP Logged
		     | 
                    
            		  
           | 
           
          
           
  | 
           
          
Interesting! Thanks Brady.
         | 
       
       
        | Back to Top | 
         
          
          
         | 
       
       
       
        |   | 
      
        
         
         dhoward Admin Group 
          
  
  Joined: June 29 2001 Location: United States
 Online Status: Offline Posts: 4447
          | 
        
         
          
           | Posted: June 30 2008 at 11:33 | IP Logged
		     | 
                    
            		  
           | 
           
          
           
  | 
           
          
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 | 
         
          
          
         | 
       
       
       
        |   | 
      
        
         
         TonyNo Moderator Group 
          
  
  Joined: December 05 2001 Location: United States
 Online Status: Offline Posts: 2889
          | 
        
         
          
           | Posted: June 30 2008 at 13:41 | IP Logged
		     | 
                    
            		  
           | 
           
          
           
  | 
           
          
Thanks for the occurrence tip!
 
 Still no go, though.    
         | 
       
       
        | Back to Top | 
         
          
          
         | 
       
       
       
        |   | 
      
        
         
         jbbtex Senior Member 
          
 
  Joined: February 15 2007 Location: United States
 Online Status: Offline Posts: 181
          | 
        
         
          
           | Posted: July 01 2008 at 17:44 | IP Logged
		     | 
                    
            		  
           | 
           
          
           
  | 
           
          
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 | 
         
          
         | 
       
       
       
        |   | 
      
        
         
         TonyNo Moderator Group 
          
  
  Joined: December 05 2001 Location: United States
 Online Status: Offline Posts: 2889
          | 
        
         
          
           | Posted: July 01 2008 at 19:50 | IP Logged
		     | 
                    
            		  
           | 
           
          
           
  | 
           
          
Interesting. This doesn't even work for me. Are you running the alpha?
         | 
       
       
        | Back to Top | 
         
          
          
         | 
       
       
       
        |   | 
      
        
         
         jbbtex Senior Member 
          
 
  Joined: February 15 2007 Location: United States
 Online Status: Offline Posts: 181
          | 
        
         
          
           | Posted: July 01 2008 at 20:12 | IP Logged
		     | 
                    
            		  
           | 
           
          
           
  | 
           
          
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 | 
         
          
         | 
       
       
       
        |   | 
      
        
         
         TonyNo Moderator Group 
          
  
  Joined: December 05 2001 Location: United States
 Online Status: Offline Posts: 2889
          | 
        
         
          
           | Posted: July 01 2008 at 23:44 | IP Logged
		     | 
                    
            		  
           | 
           
          
           
  | 
           
          
Ah! Maybe a clue!
         | 
       
       
        | Back to Top | 
         
          
          
         | 
       
       
       
        |   | 
      
        
         
         TonyNo Moderator Group 
          
  
  Joined: December 05 2001 Location: United States
 Online Status: Offline Posts: 2889
          | 
        
         
          
           | Posted: July 25 2008 at 12:46 | IP Logged
		     | 
                    
            		  
           | 
           
          
           
  | 
           
          
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 | 
         
          
          
         | 
       
       
       
        |   |