import retext = "2-f becomes 2f, f-2 becomes f2"print( re.sub(r"(\d)-(\D)|(\D)-(\d)", r"\1\2\3\4", text) )
Standard input is empty
2f becomes 2f, f2 becomes f2
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!