On Mar 30, 2007, at 2:31 PM, Stephen Smith wrote:

> But I think that the format Harry and Gary suggested clearly  
> represents the pattern I'm matching.

Just FYI, when speed matters it may be worth using unpack:

#!/usr/bin/env ruby -w

require "benchmark"

TESTS = 100_000
LINE  = "XYZ" * 100
Benchmark.bmbm do |results|
   results.report("regex:") do
     TESTS.times do
       /(.{8})(.{6})(.{15})(.{3})(.{30})(.{4})(.{15})(.{1})(.{12})(. 
{9})/.match(LINE).captures.join(",")
     end
   end
   results.report("unpack:") do
     TESTS.times do
       LINE.unpack("A8A6A15A3A30A4A15A1A12A9").join(",")
     end
   end
end
# >> Rehearsal -------------------------------------------
# >> regex:    2.060000   0.000000   2.060000 (  2.067150)
# >> unpack:   0.760000   0.000000   0.760000 (  0.762482)
# >> ---------------------------------- total: 2.820000sec
# >>
# >>               user     system      total        real
# >> regex:    2.040000   0.000000   2.040000 (  2.046938)
# >> unpack:   0.770000   0.000000   0.770000 (  0.763620)

__END__

James Edward Gray II