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

[REBOL] Re: help me parse this?

From: petr:krenzelok:trz:cz at: 5-Nov-2000 17:43

----- Original Message ----- From: <[balayo--mindspring--com]> To: <[rebol-list--rebol--com]> Sent: Sunday, November 05, 2000 9:24 AM Subject: [REBOL] help me parse this?
> hey guys, > > in my long journey toward's REBOL competency, > parse is still blocking my way. I can use the > example of extracting the title from a web page, > but how can I modify that to replace the text > between the tags to something else? > > Even if there is a way with 'find, etc, I'd still > rather do it with 'parse. anybody? > Thanks!
str: {<A HREF="http://www.rebol.com/">REBOL website</A>} parse str [ thru "<A HREF=" thru ">" start-replace: to </A> end-replace: (change/part start-replace "REBOL Technologies www site" offset? start-replace end-replace end-replace: index? start-replace) :end-replace to end ] by assigning the value - start: you tell parser to mark the input, so we marked start and end of the part of string we want to change ... then I used change/part, which will change the string. The function seems to be intelligent enough to insert rest of the string and return the series behind the point of insertion. I am not sure if required, but by putting :end back into parser we reassign position and tell parser to start right from that position