import res = "a61s8sa92s3s3as4s4af3s"pattern = r"(1s|2s|s4|3s)|[\d.]"print( re.sub(pattern, lambda x: x.group(1) or ' ', s) )
Standard input is empty
a 1s sa 2s3s as4s4af3s
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!