[REBOL] parse or Re:(3)
From: rryost:home at: 20-Sep-2000 21:30
See my stuff interjected below:
Russell [rryost--home--com]
----- Original Message -----
From: <[RChristiansen--pop--isdfa--sei-it--com]>
To: <[list--rebol--com]>
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: