----- Original Message -----
From: Terry Brownell <[EMAIL PROTECTED]>
To: Rebol List <[EMAIL PROTECTED]>
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
have you really tested your code? I receive error for above line, as 'y has
to be string, not block ...
>
> foreach val z [
> either find val "<" [append n val] [append n rejoin [{<text> } val]]
> ]
hmm, but what about if your text contains some "<" too? I think more robust
solution would be better:
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: [some [tag | (append result "<text>") start: skip (append result
copy/part start 1)]]
parse/all str [text to end]
print result
>
> But then I get
>
> n: [
> <text>
> <text> This
> <text> is
> <text> some
> <text> text
> <tag>
> <text> with
> <text> a
> <text> tag
> <text> added
> </tag>
> <text> and
> <text> then
> <text> some
> <text> text
> </text>
> ]
>
> So how do I "collect" all the text until the next "tag"?
>
> Terry Brownell
>
> --
> To unsubscribe from this list, please send an email to
> [EMAIL PROTECTED] with "unsubscribe" in the
> subject, without the quotes.
--
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the
subject, without the quotes.