python regex: get end digits from a string

前端 未结 7 701
予麋鹿
予麋鹿 2020-12-08 20:29

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\"\         


        
7条回答
  •  清歌不尽
    2020-12-08 20:55

    Save the regular expressions for something that requires more heavy lifting.

    >>> def parse_last_digits(line): return line.split('-')[-1]
    >>> s = parse_last_digits(r"99-my-name-is-John-Smith-6376827-%^-1-2-767980716")
    >>> s
    '767980716'
    

提交回复
热议问题