From: Phrogz Date: 2006-07-13T04:30:05+09:00 Subject: Re: Help with a regexp require 'strscan' s = StringScanner.new( "3:ab23:cat5:sheep" ) words = [] until s.eos? if digits = s.scan( /\d+/ ) digits = digits.to_i s.pos += 1 words << s.peek( digits ) s.pos += digits else p words abort "Couldn't find digits for: #{s.rest}" end end p words #=> ["ab2", "cat", "sheep"]