--- Xavier Noria <fxn / hashref.com> wrote:
> On Sunday 12 October 2003 05:50, Mike Campbell wrote:
> 
> > I have a line of text output in columnar form; what's the best
> way to
> > split it into its requisite parts?
> >
> > Say I have lines of
> >
> > aaaaabbcccccddeee
> >
> > I can do something like:
> >
> > md = /(.....)(..)(.....)(..)(...)/.match(line);  # seems klugy
> > somehow
> 
> If the data is a fixed-width record String#unpack is a compact
> idiom, 
> and it's usually fast as well. For instance:
> 
>     record = "aaaaabbcccccddeee"
>     fields = record.unpack("a5a2a5a2a3")


Perfect, yes.  Thanks.

__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com