s = "Line1.\r\nLine2.\rLine3.\nLine4\r\nLine5"res = s.gsub(/(\.\R+)|\R+/, '\1')puts resputs res.gsub("\r", 'CR').gsub("\n", 'LF')
Standard input is empty
Line1. Line2. Line3. Line4Line5 Line1.CRLFLine2.CRLine3.LFLine4Line5
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!