Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pyre2 anchor '$' have non standard non re compatible behaviour #41

Open
omerlaufer opened this issue May 11, 2016 · 2 comments
Open

pyre2 anchor '$' have non standard non re compatible behaviour #41

omerlaufer opened this issue May 11, 2016 · 2 comments

Comments

@omerlaufer
Copy link

documentation of gnu regex and also re module says:

This operator can match the empty string either at the end of the string or before a newline character in the string

look at this simple example:

re.findall(r'abc$', 'bla bla abc\n')
['abc']

re2.findall(r'abc$',  'bla bla abc\n')
[]

Is this behaviour is intentionally?

@andreasvc
Copy link
Collaborator

andreasvc commented May 11, 2016

Duplicate of #40.

I am curious if anyone knows a solution. RE2 doesn't provide the equivalent operator (\Z), cf. https://github.com/google/re2/wiki/Syntax

It's not enough to do \n?$ because that behaves differently in substitutions, and in this case, by including the newline in the match.

Incidentally, why do you care? I found this behavior of $ rather odd, can't see why it's desirable.

@omerlaufer
Copy link
Author

  1. this is the standard behaviour.
  2. the goal of pyre2 is:

The stated goal of this module is to be a drop-in replacement for re. to be compatible with re.

I understand if there are features that not supported, either because its fundamentally can't be done by re2 engine or just because its didn't implemented yet.
But if pyre2 behaves differently for the same regex, its not aligned with pyre2 goal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants