cookbook-在正则中使用Unicode

https://python3-cookbook.readthedocs.io/zh_CN/latest/c02/p10_work_with_unicode_in_regexp.html

import re
num = re.compile(‘\d+‘)
print(num.match(‘123‘))
print(num.match(‘\u0661\u0662\u0663‘))
<_sre.SRE_Match object; span=(0, 3), match=‘123‘>
<_sre.SRE_Match object; span=(0, 3), match=‘???‘>

相关推荐