From: "David A. Black" Date: 2005-09-26T08:26:52+09:00 Subject: Re: String#ggsub Hi -- On Mon, 26 Sep 2005, YANAGAWA Kazuhisa wrote: > In Message-Id: <1127687058.509239.99690@f14g2000cwb.googlegroups.com> > "Trans" writes: > >> Oh better: >> >> foo.gsub!( /.../, ... ) while $~ > > irb(main):001:0> s = 'foo' > => "foo" > irb(main):002:0> s =~ /never match/ > => nil > irb(main):003:0> s.gsub!(/\w/, '*') while $~ > => nil > irb(main):004:0> s > => "foo" > > So that's not context free. > > I tend to use > > true while s.gsub!(/.../, ...) > > but probably OP doesn't like that because of extra `true'. If you had reason to save the last match, you could do: m = $~ while s.gsub!(/.../, ...) :-) Also this would work, but it's probably too verbose: begin s.gsub!(/\w/,"*") end while $~ David -- David A. Black dblack@wobblini.net