Skip to content

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

@eligro91

Description

@eligro91

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions