Basically I want to know how I would do this.
Here's an example string:
string = "hello123"
import re m = re.search(r'\d+$', string) # if the string ends in digits m will be a Match object, or None otherwise. if m is not None: print m.group()
\d matches a numerical digit,
\d+ means match one-or-more digits (greedy: match as many consecutive as possible). And
$ means match the end of the string.