fork download
  1. import re
  2. text = "UURRUULLLRRDDDBBBUUU"
  3. print( re.sub(r"(.)\1*", lambda x: "{}{}".format(len(x.group()), x.group(1)), text) )
Success #stdin #stdout 0.03s 9636KB
stdin
Standard input is empty
stdout
2U2R2U3L2R3D3B3U