コードの世界より。
irb(main):001:0> msg = "abcdefg" => "abcdefg" irb(main):029:0* msg.sub(/a(.*?)efg/ , "*\\0*") => "*abcdefg*" irb(main):031:0> msg.sub(/a(.*?)efg/ , "*\\&*") => "*abcdefg*" irb(main):032:0> msg.sub(/a(.*?)e/ , "*\\&*") => "*abcde*fg" irb(main):033:0> msg.sub(/a(.*?)e/ , "*\\1*") => "*bcd*fg" irb(main):034:0> msg.sub(/a(.*?)efg/ , "*\\&*") => "*abcdefg*"