开发者

python regex [:alpha:]

I'm using this regex in Python:

import re

>>> ER = re.compile('^\w{0,30}$', re.U)

>>> ER.sub('.', 'Maçã')

>>>....

But a wanna catch only letters, [A-Z] does not wo开发者_如何学Gork for me, because i need letters with accent . Is there any way to use POSIX? [:alpha:], something like that or another solution?

Thanks!


Modified the regex - how about

ER = re.compile(u'^[^\W\d_]{1,30}$', re.U)
s = ER.sub(u'.', u'Maçã')

matches u'Maçã' but not u'Maçã01'.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜