From: "David A. Black" Date: 2004-09-28T07:15:26+09:00 Subject: Re: keep changes in string outside of scope? Hi -- On Tue, 28 Sep 2004, Matthew Margolis wrote: > David A. Black wrote: > > >Hi -- > > > >On Tue, 28 Sep 2004, David A. Black wrote: > > > > > > > >> thestring.sub!(/\d{5}/) {|x| "#{x},"} > >> > >> > > > >Amendment: as James G. suggested, use gsub! if you have more than one > >in one string :-) Also make sure that you have no street numbers with > >five digits in a row. > > > > > >David > > > > > > > Excellent. I didn't know that each returned new objects. Thanks a > bunch guys. Just to clarify: it (each) doesn't always return new objects; it depends on the particular case. For example, in the case of Array#each, you do get the actual array element. With strings, the effect is like splitting the string into lines, i.e., substrings. David -- David A. Black dblack@wobblini.net