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 18:02

Answering once again, as I am not really used to Outlook Express and pressed wrong key combination so my email was accidentally sent to the list .... Ignore my previous message ... ----- 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: (offset: offset? start-replace end-replace end-replace: change/part start-replace "REBOL Technologies www site" offset ) :end-replace copy rest to end (print rest) to end ] by assigning the value to start-replace: 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, so we reassigned 'end-replace ... Then we need to return the position back to parser by :end-replace .... To see we are in the right position I assigned rest of the string to 'rest word and printed it ... having 'replace as part of parser dialect was one of my suggestions to current parser implementation ... HopeThisHelps a little bit, Cheers, -pekr-