Identifying unicode punctuation characters with Python regex
"Martin v. Löwis"
martin at v.loewis.de
Fri Nov 14 05:27:46 EST 2008
> I'm trying to build a regex in python to identify punctuation
> characters in all the languages. Some regex implementations support an
> extended syntax \p{P} that does just that. As far as I know, python re
> doesn't. Any idea of a possible alternative?
You should use character classes. You can generate them automatically
from the unicodedata module: check whether unicodedata.category(c)
starts with "P".
Regards,
Martin
More information about the Python-list
mailing list