fork(2) download
  1. import re
  2. s = ['e004_n07','e000_n00']
  3. res = [re.sub(r'(?<=[a-zA-Z])0+(\d*)', lambda m: m.group(1) if m.group(1) else '0', x) for x in s]
  4. print(res)
Success #stdin #stdout 0.01s 9024KB
stdin
Standard input is empty
stdout
['e4_n7', 'e0_n0']