import rew = 'w123 o456 t789-- --'print(re.sub(r'^(.*\d).*$', r'\1', w, flags=re.S))
Standard input is empty
w123 o456 t789
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!