Skip to content

Instantly share code, notes, and snippets.

@natbusa
Last active November 2, 2016 09:27
Show Gist options
  • Save natbusa/9dbeae216bd8e50d76a69ae214b913ce to your computer and use it in GitHub Desktop.
Save natbusa/9dbeae216bd8e50d76a69ae214b913ce to your computer and use it in GitHub Desktop.
Separate trailing digits from the rest of the string
import re
def trailing_digits(str):
m = re.search('^[0-9]*', str)
return (str[m.start():m.end()], str[m.end():])
#> trailing_digits('1234 hollywood boulevard')
#> ('1234', ' hollywood boulevard')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment