Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: Parse limitation ?

From: lmecir:mbox:vol:cz at: 8-Oct-2003 14:23

Hi Pat, ----- Original Message ----- From: "patrick à la poste"
> Hi List, > > I'd like to parse a string searching for two things at the same time. > it seems to me that this is impossible. > > For example, a text from which I want to extract the HREF and the SRC target. > > myText: {<A HREF="#section1"><IMG SRC="foobar.gif"><A HREF="#section1">} > > parse myText [ > any [ thru "HREF=" copy target to ">" (print target) | > thru "SRC=" copy target to ">" (print target) > ] ; any > ] ; parse > > "#section1" > "#section1" > > parse myText [ > any [ thru "SRC=" copy target to ">" (print target) | > thru "HREF=" copy target to ">" (print target) > ] ; any > ] ; parse > > "foobar.gif" > "#section1" > > The result is different depending which rule comes first. The only way I see as a workaround is to parse the text twice. Is there a better (smarter) way? > > Regards > Patrick
This is possible with PARSE. You can use my parse enhancements e.g. Have a look at: http://www.fm.vslib.cz/~ladislav/rebol/parseen.r Ladislav