fork download
  1. import re
  2. text = "126 2225xx009"
  3. rx = r"\b(?:[a-z]+[0-9]+|[0-9]+[a-z]+)[a-z0-9]*\b|\d+"
  4. print(re.sub(rx, lambda x: " ".join(x.group()), text))
  5.  
  6.  
Success #stdin #stdout 0.02s 9528KB
stdin
Standard input is empty
stdout
1 2 6 2 2 2 5 x x 0 0 9