I am quite new to python and regex (regex newbie here), and I have the following simple string:
s=r\"\"\"99-my-name-is-John-Smith-6376827-%^-1-2-767980716\"\
Nice and simple with findall
:
import re
s=r"""99-my-name-is-John-Smith-6376827-%^-1-2-767980716"""
print re.findall('^.*-([0-9]+)$',s)
>>> ['767980716']
Regex Explanation:
^ # Match the start of the string
.* # Followed by anthing
- # Upto the last hyphen
([0-9]+) # Capture the digits after the hyphen
$ # Upto the end of the string
Or more simply just match the digits followed at the end of the string '([0-9]+)$'