This is a bug of version 0.2.20. See this issue or this one. You'd better clone the source from github and then install it. Don't install it via pip.
Why re2 result different from re module in Python?
Domanda
I try to use re2.
import re
print re.search('cde', 'abcdefg').group(0)
Result:
cde
But re2 result is different
import re2
print re2.search('cde', 'abcdefg').group(0)
Result:
1
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'NoneType' object has no attribute 'group'
- Why
re2
output number 1 when every execution new string pattern? - How to hide the number 1?
- Why the result is different with
re module
(not found => return None)?
The re2 version is 0.2.20. and Python is 2.7
Thank you
Soluzione
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow