fork download
  1. import re
  2.  
  3. rx = r'([0-9]+)|([A-Z]+)|[a-z]+'
  4. w = "XXXxxx999XX"
  5.  
  6. def repl(m):
  7. if m.group(1):
  8. return '9'
  9. elif m.group(2):
  10. return 'X'
  11. else:
  12. return 'x'
  13.  
  14. print(re.sub(rx, repl, w))
Success #stdin #stdout 0.02s 27760KB
stdin
Standard input is empty
stdout
Xx9X