How can I strip everything leading up to a number? Of course this would have to work for any number, not just 1.
I would like blahblahblah 1 main street as input. And 1 main street as output.
You can use itertools.dropwhile. Drops everthing before a '1' (or any other number) is reached:
from itertools import dropwhile
s = 'blahblahblah 1 main street'
r = ''.join(dropwhile(lambda x: not x.isdigit(), s))
print(r)
# '1 main street'
Works with all numbers
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With