> but what if I don't want to include the <xxxx> in 'name?
>
> >> parse line1 [thru {"} copy name [to {<} 4 digits {>} (print name)] to
end]
> -------------------------------------| Note the 'thru changed to 'to
> == false
>
> That doesn't make sense.

'to recognises the "<" and stops just before the "<" in the string. You'll
need to use:
        thru "<"
    to get "thru" it.

> Now the second problem:
>
> >> line2: {Lets find "J<o>hn<1234>"}
> >> parse line2 [thru {"} copy name [thru {<} 4 digits {>} (print name)] to
end]
> == false
>
> So there's the second problem, parse seems to get stuck on '<o>'. I would
assume the sub rule should only match a string containing '<xxxx>' and x is
a digit.

No, the rule hasn't yet got there.

        {Lets find "J<o>hn<1234>"}    ; Before
            [thru {"}
                   {J<o>hn<1234>"}    ; After [thru {"}
               thru {<}
                     {o>hn<1234>"}    ; After [thru {<}
                      4 digits
                      Parse fails here because "o" (lower case letter "O")
isn't a character that matches the 'digits bitset.

> Finally the follow line causes the rebol console to hang:
>
> >>parse line2 [thru {"} copy name [some [to {<}]] to end]
>
> and once again I can't get my head around it.

        {Lets find "J<o>hn<1234>"}    ; Before
          [some [to {<}]]
                    {<o>hn<1234>"}    ; After
    Note that 'to doesn't go "thru" it's match. 'some specifies one or more
matches of the thing to the right. Because 'to doesn't go through it's
match, 'some keeps repeating the 'to "<" as it keeps matching (and not going
through the input). So you have an infinite loop, so the rebol console
hangs. I believe this is called "greedy parsing".

> Clearly the manual needs more detail on 'parse.

I agree. Rebol is still in a state of flux, though.

I hope that helps!

Andrew Martin
No longer so greedy...
ICQ: 26227169 http://members.nbci.com/AndrewMartin/
-><-


-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.

Reply via email to