in reply to Regular expression to remove ^M

^M is a representation for Carriage Return. s/\x0D//g; should have worked. s/\r//g; is another way.