[REBOL] Re: Parse question
From: volker::nitsch::gmail::com at: 31-Jul-2005 3:59
On 7/31/05, Kai Peters <[kpeters--vu-ware--com]> wrote:
> Hi Parsers ~ =A0 why does parse below not return= true? =A0 Thanks, Kai =A0
> =A0 >>=A0st: "Kai was= here" == "Kai was here" >>=A0parse/all st [ thru
> "ai" copy chunk to "here" ] == false >>=A0probe= chunk " was > was " >>
str: {
Hi Parsers ~ =A0 why does parse below not return= true? =A0 Thanks, Kai =A0
=A0 >>=A0st: "Kai was= here" == "Kai was here" >>=A0parse/all st [ thruai
copy chunk to "here" ] == false >>=A0probe= chunk " was " == "
was " >>
--}
letternum: charset[#"A" - #"Z" #"0" - #"9"]
parse/all str[
any[to "=" [p: "=" 2 letternum (remove/part p 3) :p ] | skip]
]
replace/all str " >>" "^/!>>"
replace/all str "= " " "
? str
{
STR is a string of value: {
Hi Parsers ~ why does parse below not return true? Thanks, Kai
!>>st: "Kai was here" "Kai was here"
!>>parse/all st [ thruai
copy chunk to "here" ] false
!>>probe chunk " was " "
was "
!>>
--}
Ok, now i get it. :)
because the string must match upto the end.
In your example the parsing goes to the "here", not thru,
so not skipping it. you must skip that yourself. Some variants:
to "here" to end ;; not exact, stuff can follow after "here"
to "here" "here" ;; goes to "here" and then skips
to "here" 4 skip ;; ""
its somewhat ugly, having something like this would be nice:
to "here" skip-last
}
> --
> To unsubscribe from the list, just send an email to
> lists at rebol.com with unsubscribe as the subject.
>
--
-Volker
Any problem in computer science can be solved with another layer of
indirection. But that usually will create another problem.
David
Wheeler