From: Robin Stocker Date: 2006-08-13T08:04:44+09:00 Subject: Re: ruby equiv of perl pos gga wrote: > This is simpler to write, but will be slower on longer strings. You're right, it's much slower! I didn't think about speed while writing it, thanks for pointing it out. Another question: Why do you use Regexp.last_match? Maybe to have a more general solution? The following seems to be simpler and faster: def test_b result = '' pos = 0 while pos = @string.index("\0", pos) result << '\%o' % pos pos += 1 end return result end