I played around with the necessary mechanisms to emulate //g Regexp behaviour in Ruby, but I'm not too happy about how much extra work I would have to do.

It would be very nice/useful to be able to do:

while md = /foo/g.match(foostr)
  puts md.to_s
  foostr = md.post_match
end

IMO, this would involve modifications to both Regexp and String classes. Strings would need to carry around the position of the last match against the string. Regexp would have a new method, #gmatch (instead of //g).

Alternatively, instead of modifying String, maybe MatchData could be modified and the new Regexp#gmatch could accept a MatchData or a String.

-a
-- 
austin ziegler
Sent from my Treo