From: Andrew Johnson Date: 2004-09-30T00:05:04+09:00 Subject: Re: scan regular expression and strings On Wed, 29 Sep 2004 23:34:25 +0900, 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? You want to use .gsub! instead of .scan. A simple approach: tr="meet" tr.gsub!(/(.)(\1)/, '\1X\2') print tr Of course if you want "meeet" to become "meXeXet" then the above won't be good enough and you'll want to use look-aheads to avoid consuming each following 'e': tr="meeet" tr.gsub!(/(.)(?=\1)/, '\1X') print tr regards, andrew