Hello [EMAIL PROTECTED]!
On 17-Dic-99, you wrote:
B> I can easily perform this function with practically no
B> programming in Perl, but I need to do it in REBOL, and I'd
B> like to do it with a single 'PARSE statement. I've tried
With PARSE? One way could be:
parse/all text [
any [
copy line to newline skip (
either none? line [
end-paragraph
] [
append-to-current-paragraph line
]
)
]
copy line to end (
if not none? line [append-to-current-paragraph line]
end-paragraph
)
]
Notice that this is almost equivalent to:
lines: read/lines text-file
foreach line lines [
either empty? line [
end-paragraph
] [
append-to-current-paragraph line
]
]
end-paragraph
You may want to trim lines to be able to consider a line a spaces
only as an empty line.
Another way with PARSE (probably better than the above):
spaces: charset " ^-"
end-of-par: [newline some [any spaces newline]]
parse/all text [
par-start:
some [
to newline [
par-end: end-of-par (
paragraph: copy/part par-start par-end
; do something with paragraph
) par-start: |
skip
]
]
(paragraph: copy par-start) ; last paragraph
]
Regards,
Gabriele.
--
o--------------------) .-^-. (----------------------------------o
| Gabriele Santilli / /_/_\_\ \ Amiga Group Italia --- L'Aquila |
| GIESSE on IRC \ \-\_/-/ / http://www.amyresource.it/AGI/ |
o--------------------) `-v-' (----------------------------------o