0
我目前在python中使用re2,re和pcre来进行正则表达式匹配。当我使用正则表达式,如re.compile(“(?P(\ S *))”)它很好,编译没有错误,但当我使用unicode字符,如re.compile(“(?P <årsag> (\ S *))“),那么会出现错误,无法编译。是否有任何Python库完全支持unicode。在python组捕获中对正则表达式的Unicode支持
编辑:请参考我的输出:
>>> import regex
>>> m = regex.compile(r"(?P<årsag>(\S*))")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/regex.py", line 331, in compile
return _compile(pattern, flags, kwargs)
File "/usr/local/lib/python2.7/site-packages/regex.py", line 499, in _compile
caught_exception.pos)
_regex_core.error: bad character in group name at position 10
谢谢,但它仍然不支持...仍然有错误“_regex_core.error:组名称中位置10的坏字符”。任何更改都需要应用? – Jiwan 2015-04-02 07:23:17
它在3.4中正常工作 – 2015-04-02 07:27:32
我在mac中使用Python 2.7.9 – Jiwan 2015-04-02 07:33:09