[REBOL] Re: Read/lines on a string!
From: ale870::gmail::com at: 20-Sep-2007 22:20
What is " ?? line " ?
On 9/20/07, Anton Rolls <anton-wilddsl.net.au> wrote:
>
> Hi Ed,
>
> It's not such a difficult parse, I think,
> for your final step. Try this:
>
> >> parse/all data [any [copy line to "^/" skip (?? line)] copy line to end
> (?? line)]
> line: {"line1 item1","line1 item2","line 1 item3"}
> line: {"line2, 'alleged'||item1","None","line2 item3"}
> line: none
> == true
>
> Just put the lines in a block.
>
> By the way,
>
> remove a insert a "|"
>
> should be faster as:
>
> change a "|"
>
> Anton.
>
> > After my de-cluttering, I have a much cleaner string which is
> > easy to work with:
> >
> > >> probe data
> > == {"line1 item1","line1 item2","line 1 item3"
> > "line2, 'alleged'||item1","None","line2 item3"
> > }
> >
> > Or is it? From here, it seems obvious to use a simple 'parse split
> > operation on the "^/". Not so fast. A simple parse split rule fails
> > (e.g., parse/all data "^/"), and parse tries to seduce me into writing
> > a set of grammar rules. I decline. I'm a busy man, parse.
> >
> > I follow the path of least resistance, first saving the data and then
> > re-opening the file using 'read/lines:
> >
> > >> write tmp: %data-temp.txt data
> > ...
> > >> data: read/lines tmp
> >
> > I'm not proud of it, but this gets me back on track. I have a block of
> > strings, all neat-and-tidy for processing.
> >
> > For my quick-and-dirty script, I'm not overly concerned about writing
> > and re-opening a temp file. But it would be nice if I could use
> > read/lines or a similar function directly on the string in memory,
> > without writing a complex parse rule.
> >
> > Is there a function which can perform this (a read/lines) on a string?
> > Was I foolish to resist parse? Does anyone have better ideas for
> > working with these types of data files?
> >
> > Thanks
>
> --
> To unsubscribe from the list, just send an email to
> lists at rebol.com with unsubscribe as the subject.
>
--
//Alessandro
http://sguish.wordpress.com
http://laccio.wordpress.com