I don't think I understand; "putting it back in" doesn't matter here, nor does using gsub instead of, say, scan. irb(main):006:0> s = 'ababababa' => "ababababa" irb(main):007:0> s.gsub(/aba/, 'aca') => "acabacaba" irb(main):008:0> s.scan /aba/ => ["aba", "aba"] irb(main):011:0> s.scan /(?=aba)/ => ["", "", "", ""] Note how the first scan returned two results, even though you can clearly see "aba" appears in the string 4 times. Note how the second returned 4 matches (even if they're all empty). Once a character is matched, regex engine moves forward, discarding everything up to the end of match, inclusive. -- Matma Rex