Reputation: 25557
I have a list of simple names such as Márquez
,
because of the á
(?< name >[a-zA-Z]+)
doesn't seem to be working!
Help would be very much appreciated!
Upvotes: 1
Views: 766
Reputation: 8604
For Python < 3 you may want to enable locale:
import locale
locale.setlocale(locale.LC_ALL, '')
And then use re.LOCALE
option with your regexpes:
re.findall('\w+', 'Márquez', re.LOCALE)
Though, probably Unicode is the better way to go, though it requires decoding the data from and encoding it to your local encoding.
Upvotes: 0
Reputation: 319601
you could use
\w+
with the unicode flag. I assume there's no risk of having digits or underscore in your names.
>>> re.findall('\w+', 'Márquez', re.U)
['Márquez']
You also seem to be missing P
after the question mark: (?P< name >[a-zA-Z]+)
Upvotes: 3