axiak / pyre2

Python wrapper for RE2
BSD 3-Clause "New" or "Revised" License
295 stars 39 forks source link

inconstitance between re and re2 on match strings with newlines #40

Open eligro91 opened 8 years ago

eligro91 commented 8 years ago

see:

git clone https://github.com/axiak/pyre2.git
Cloning into 'pyre2'...
...
....
(env)Eliyahus-MacBook-Pro:~ eliyahugromman$ cd pyre2/
(env)Eliyahus-MacBook-Pro:pyre2 eliyahugromman$ python setup.py install
....
....
(env)Eliyahus-MacBook-Pro:pyre2 eliyahugromman$ pip freeze | grep re2
re2==0.2.23
(env)Eliyahus-MacBook-Pro:pyre2 eliyahugromman$ python
Python 2.7.10 (default, Oct 23 2015, 18:05:06)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import re
>>> import re2
>>> pat = u'^.*?[-]+$'
>>> txt = u'''------------------------------------------------------
... '''
>>> re.match(pat, txt)
<_sre.SRE_Match object at 0x101c0e578>
>>> re2.match(pat, txt)
>>>

According to the docs for re $ matches "the end of the string or just before the newline at the end of the string". It seems re2 doesn't do this