[REBOL] Re: Need help from parsing professionals
From: sqlab:gmx at: 27-Jul-2001 14:30
> Hi Thorsten
> > Hi,
> > it is obviously not a big thing.
> > I have a big string. from this string i need to make a readable file
> > lots of lines. So every line starts with AA......
> > The Line ends when the next Line with AA comes up.
> > What i tried now was following:
> > a: read %/c/temp/test.txt
> > parse a [any [to "AA201" mark: to "AA" (write/append %/c/temp/new.txt
> > mark "^/")]]
> > This seems to run in an endless loop and looking in the new.txt it
> > that the parser didn't recognise the "AA201", because he always adds the
> > whole big string in one part, not the parts of the string as lines.
> At first you should advance the focus as in
> to "AA201" mark: skip 2 to "AA"
As I misplaced the parameter to skip, I will deliver a correct version
b: a: read %/c/temp/test.txt
parse next a [ some [to "AA201" a: (
write/append/lines %/c/temp/new.txt copy/part b a
) b: 4 skip
> mark sets only a pointer in the string, so your next write/append appends
> always from this point until the end of the string.
> Of course you could use a copy to or a copy/part with a second pointer.
> But why do you not just replace/all next a "AA201" "^/AA201" ?
GMXler aufgepasst - jetzt viele 1&1 New WebHosting Pakete ohne
Einrichtungsgebuehr + 1 Monat Grundgebuehrbefreiung!