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