On Aug 13, 2006, at 3:40 PM, gga wrote: > > Logan Capaldo ha escrito: > >> if perldoc -f pos is describing what pos does in this case, >> >> new_string = "" >> while pos = string =~ /\0/g >> new_string << "%o" % (pos - 1) >> end > > This won't work. Regexp in ruby does not support Perl's /g option. > You need to use String.index() with a position modifier as I showed > before or gsub in case of a global regexp replacement. > > Oops, out of practice with my perl. Forgot that /g with a while loop was how you did #scan { } in perl. How about: new_string = "" string.scan(/\0/) do |m| new_string = "%o" % $~.offset(0).first end