fork(1) download
  1. import re
  2. rx_R = r'(?:\u000D\u000A|[\u000A\u000B\u000C\u000D\u0085\u2028\u2029])'
  3. s = "Line1.\r\nLine2.\rLine3.\nLine4\r\nLine5"
  4. res = re.sub(r'(\.{0})|{0}'.format(rx_R), lambda x: x.group(1) if x.group(1) else '', s)
  5. print(res)
  6. print(res.replace("\n", "LF").replace("\r", "CR"))
Success #stdin #stdout 0s 23352KB
stdin
Standard input is empty
stdout
Line1.
Line.
Line3.
Line4
Line
Line1.CRLFLine.CRLine3.LFLine4CRLFLine