Hi,
Whoops! Just noticed that the "works like a charm" parse statement misses
the last paragraph sometimes.
I modified this:
parse read b [some [copy c to "^/^/" (append a c) any "^/"] to end ]
to this:
parse read b [some [copy c to "^/^/" (append a c) any "^/"] copy c to
end (append a c)]
and it seems to work. I'm still trying to understand this type of parse
statement better, so until I do, I may still have to tweak it a little.
Regards,
Bernie Schneider
Systems Analyst
CIBER, Inc.
303-224-4159
[EMAIL PROTECTED]
> -----Original Message-----
> From: [EMAIL PROTECTED] [SMTP:[EMAIL PROTECTED]]
> Sent: Tuesday, December 21, 1999 2:03 PM
> To: [EMAIL PROTECTED]
> Subject: [REBOL] Parsing Paragraphs Re:(2)
>
> Hi,
>
> Whoops! Just noticed that the "works like a charm" parse statement misses
> the last paragraph sometimes.
>
> I modified this:
>
> parse read b [some [copy c to "^/^/" (append a c) any "^/"] to end ]
>
> to this:
>
> parse read b [some [copy c to "^/^/" (append a c) any "^/"] copy c to
> end (append a c)]
>
> and it seems to work. I'm still trying to understand this type of parse
> statement better, so until I do, I may still nave to tweak it a little.
>
> I wrote
>
> This works like a charm. I was that close, left the 'any "^/"' part out of
> the sub-rule. Thanks a lot.
>
> I got other suggestions from the list also. I'm very grateful for all of
> the
> help.
>
> Regards,
>
>
> Bernie Schneider
> Systems Analyst
> CIBER, Inc.
> 303-224-4159
> [EMAIL PROTECTED]
>
> > -----Original Message-----
> > From: [EMAIL PROTECTED] [SMTP:[EMAIL PROTECTED]]
> > Sent: Saturday, December 18, 1999 12:20 AM
> > To: [EMAIL PROTECTED]
> > Subject: [REBOL] Parsing Paragraphs Re:
> >
> > you can try:
> > parse-para: func [ b [file!]][
> > a: make block! 200
> > copy a []
> > parse read b [some [copy c to "^/^/" (append a c) any "^/"] to end ]
> > return a
> > ] ;end function
> > i.e: textfile content:
> > "this is first para
> >
> > this is second para
> >
> >
> > this is third para
> > this is third para also "
> > parse-para %textfile
> > ----the results-----
> > ["this is first para" "this is second para " "this is third para ^/
> this
> > third para also]
> > this maybe what you want
> >
> > ---gerry
> >
> > ----- Original Message -----
> > From: <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Saturday, December 18, 1999 3:18 AM
> > Subject: [REBOL] Parsing Paragraphs
> >
> >
> > > Hi Group,
> > >
> > > It's common in text file processing to have to break the file up into
> > > paragraphs, where a paragraph is defined to be one or more text lines
> > > followed by one or more blank lines (i.e., two or more newline
> > characters).
> > > Newline characters within each paragraph must be preserved, and each
> > > paragraph is to be appended to a block.
> > >
> > > I can easily perform this function with practically no programming in
> > Perl,
> > > but I need to do it in REBOL, and I'd like to do it with a single
> 'PARSE
> > > statement. I've tried literally hundreds of variations of parse rules,
> > but
> > > the best I've been able to do so far, is to get only the first two
> > > paragraphs, all the rest disappear somewhere. I haven't found any
> > examples
> > > in the docs or the program libraries.
> > >
> > > Can anyone think of a way to parse a file into paragraphs?
> > >
> > > TIA,
> > >
> > >
> > > Bernie Schneider
> > > Systems Analyst
> > > CIBER, Inc.
> > > 303-224-4159
> > > [EMAIL PROTECTED]
> > >
> > >