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

[REBOL] Re: Complex Series Parsing (Part 2)

From: petr:krenzelok:trz:cz at: 8-Mar-2001 23:34

----- Original Message ----- From: Terry Brownell <[depotcity--home--com]> To: Rebol List <[rebol-list--rebol--com]> Sent: Thursday, March 08, 2001 9:28 PM Subject: [REBOL] Complex Series Parsing (Part 2)
> Hello all. > > How do you parse this... > y: [ > <text> This is some text <tag> with a tag added </tag> and then some text
</text>
> ] > > So that you get this > > n: [ > <text> This is some text > <tag> > <text> with a tag added > </tag> > <text> and then some text > ] > > I tried this... > > n: [] > z: parse y none > > foreach val z [ > either find val "<" [append n val] [append n rejoin [{<text> } val]] > ] >
str: "<text> This is some text <tag> with a tag added </tag> and then some text </text>" result: copy "" alpha: charset [#"A" - #"Z" #"a" - #"z"] tag: [start: "<" [some alpha | "/" some alpha] ">" end: (tmp: copy/part start end append result either tmp ="<text>" ["<text>"][join newline [tmp newline "<text>"]])] text: [some [tag | start: skip (append result copy/part start 1)]] parse/all str [text to end] print result