#GNU Sed, 33 Score includes +2 for `-rn` options to sed. This is almost a direct port of @FryAmTheEggman's [Retina answer][1]: : s/(\w)(.*,.*)\1/\2/i t /\w/Q1 [Ideone.][2] [1]: http://codegolf.stackexchange.com/a/74183/11259 [2]: https://ideone.com/ANy32v