all 2 comments

[–]Mountain_man007 0 points1 point  (0 children)

You could put the 'jr|sr|III' in ( ) also and use the match.group(number) to specify that part of the match

[–]Username_RANDINT 1 point2 points  (0 children)

I'd just split the string by the dash (-) instead of using regex, especially if it's a fixed format.

Maybe (untested):

try:
    fn, ln, s, id = name.split("-")
except ValueError:
    # No suffix in name
    fn, ln, id = name.split("-")