http://qs321.pair.com?node_id=1036473


in reply to Re^2: Remove duplicate from the same line..
in thread Remove duplicate from the same line..

Adding .* after \1 in Atanasius' solution should do the trick as it matches everything up to the trailing \n.