From: Craig Demyanovich Date: 2008-10-21T00:04:07+09:00 Subject: Re: Way to split a string based on fixed length? ------=_Part_30130_9954142.1224515117886 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline I thought String#split with a regex might do it, but I'm not sure why it returns an array with empty strings in it. So I tried String#scan. It works, but since we're grouping into runs of eight characters, it returns an array of arrays of results. No problem, we can just use Array#flatten to take care of that. Here's IRB output showing the approaches: >> '0000000N0000000N0000000N0000000N'.split(/(\w{8})/) => ["", "0000000N", "", "0000000N", "", "0000000N", "", "0000000N"] >> '0000000N0000000N0000000N0000000N'.scan(/(\w{8})/) => [["0000000N"], ["0000000N"], ["0000000N"], ["0000000N"]] >> '0000000N0000000N0000000N0000000N'.scan(/(\w{8})/).flatten => ["0000000N", "0000000N", "0000000N", "0000000N"] Regards, Craig ------=_Part_30130_9954142.1224515117886--