From: "Brian Schröder" Date: 2004-09-29T23:50:23+09:00 Subject: Re: scan regular expression and strings STEPHEN BECKER I V wrote: >tr="meet" >tr.scan(/(.)\1/) {|x| x=x+'x'} >print tr > >What I want it to do is find doubles like the ee in meet and put an x >between them. Am i doing this wrong because x is part of an array now? > > > Your change to x is local to the block, because x is a new string object on each iteration, that is not connected to tr. You can achieve your aim like this: Warning: Untested, but the idea should be clear. x = "meet meep meep" y = x.gsub(/(.)(\1)/, '\1x\2') Observe that this does not change the string x, but the result will be allocated in y. If you want to change the original string use gsub!. Regards, Brian