From: Ryan Flynn Date: 2004-09-30T00:50:31+09:00 Subject: Re: scan regular expression and strings > x = "meet meep meep" > y = x.gsub(/(.)(\1)/, '\1x\2') $ irb irb(main):001:0> $_="meeet" => "meeet" irb(main):002:0> gsub(/(.)(\1)/, '\1x\2') => "mexeet" irb(main):003:0> gsub(/(.)\1/, '\1x\1') => "mexexet" irb(main):004:0> i figured it'd be more efficient not to capture the second instance, and just use \1 again in the replacement since it's the same character; however, i also got a different ("more correct" i think) result... do ruby regexes not advance past what they don't capture? i expected the second one to be slightly more efficient but i expected the behavior to be identical... can anyone shed some light?