From: Andrew Stewart Date: 2007-03-30T17:28:02+09:00 Subject: Re: text processing On 30 Mar 2007, at 06:49, Gary Wright wrote: > On Mar 30, 2007, at 1:25 AM, Harry wrote: >> x =~ /(...)(.)(....)/ #grabs 3 characters, then 1, then 4 >> mydata << $1 + "," + $2 + "," + $3 + "\n" > > mydata << /(...)(.)(....)/.match(x).captures.join(',') << "\n" If your fixed-width fields are more than, say, five characters wide, your regexp would be clearer by specifying the number of occurrences of each group rather than writing a . for each occurrence. I.e.: mydata << /(.{3})(.)(.{4})/.match(x).captures.join(',') << "\n" Regards, Andy Stewart