Python Regex: Finding First and Last Names
I have a bunch of names in a string, and each first + last name is located
within '>' and '>'s. So, the string could be, for example
'uselessdataetc<Michael Bloomberg>blahblah<William Handler>blahblah' and
I'd want it to return 'Michael Bloomberg', 'William Handler'
This is the regex I'm using:
nameregex = '<([a-z]+|\s)*>'
I'm using re.IGNORECASE when using the regex. It's currently only
returning last names. So it's returning 'Bloomberg', 'Handler'.
Can anyone see why this is happening?
No comments:
Post a Comment