import retext = "126 2225xx009"rx = r"\b(?:[a-z]+[0-9]+|[0-9]+[a-z]+)[a-z0-9]*\b|\d+"print(re.sub(rx, lambda x: " ".join(x.group()), text))
Standard input is empty
1 2 6 2 2 2 5 x x 0 0 9
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!