See my stuff interjected below:

Russell [EMAIL PROTECTED]
----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, September 20, 2000 1:54 PM
Subject: [REBOL] parse or Re:(2)


> > paragraphs: {First paragraph.^/Second "paragraph."^/Third paragraph.}
> > parse paragraphs [some [thru {.^/}  | thru {."^/} | thru "." end]]
>
> This returns "true"
>
> But what if I'm trying to parse a report and wish to make each
> paragraph a separate string within a block?

Simple parsing with the /all refinement will do this in one step.  The /all
refiinement disables all the default delimiters and uses only the supplied
string of characters to break apart the target string. In this case, we'll
use the control character "^/", end of line, commonly used to end a
paragraph.

A console session follows  that illustrates this. ( Note I've inserted an
extra "test" period within the first paragraph.)

>> paragraphs: {First. paragraph.^/Second "paragraph."^/Third paragraph.}
== {First. paragraph.
Second "paragraph."
Third paragraph.}

>> ; Now apply the simple parse/all with only the single break character
"^/"

>> parse/all paragraphs "^/"
== ["First. paragraph." {Second "paragraph."} "Third paragraph."]

end of console session.

This seems to be just what is wanted.  {}'s are used for the second item
because it included " 's.  The period at the end of First is ignored, along
with all the other spaces, ", etc because the /all refinement disabled the
usual default break chars.
.
The previous message now continues:

>>
>
> >> paragraphs: {First paragraph.^/Second "paragraph."^/Third
> paragraph.}
> == {First paragraph.
> Second "paragraph."
> Third paragraph.}
> >>
> >> paragraphs-breakdown: []
> == []
> >>
> >> foreach paragraph parse paragraphs [some [thru {.^/}  | thru {."^/} |
> thru "." end]] [append paragraphs-breakdown paragraph]
> ** Script Error: foreach expected data argument of type: series.
> ** Where: foreach paragraph parse paragraphs [some [thru ".^/" | thru
> {."} | thru "." end]]
>
>
> Doesn't work.
>
> Sorry if I'm being a pain, but when I read the "parse rules"
> documentation it doesn't make any sense to me. I can't see the
> usefulness of returning "true" in this situation.
>
> >
> >   -jeff
> >
> > > == {First paragraph.
> > > Second "paragraph."
> > > Third paragraph.}
> > > >> probe parse paragraphs [{.^/} | {."^/}]
> > > false
> > > == false
> > > >> probe parse paragraphs ({.^/} or {."^/})
> > > ** Script Error: Cannot use or~ on string! value.
> > > ** Where: ".^/" or {."
> > >
> > > So how DO I parse by a value OR another value?
> > >
> > > -Ryan
> >
>
>

Reply via email to