fork(1) download
  1. import re
  2. text = '52A, XYZ Street, ABC District, 2, M, Brown'
  3. p = r'^(.*?)(,?\s*\b\d+\b)'
  4. text = re.sub(p, lambda x: "{}{}".format(x.group(1).replace(',', ''), x.group(2)), text)
  5. print(text)
Success #stdin #stdout 0.02s 6960KB
stdin
Standard input is empty
stdout
52A XYZ Street ABC District, 2, M, Brown