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

Support for RE2 #58

Open
ddn0 opened this issue Mar 26, 2024 · 3 comments · May be fixed by #67
Open

Support for RE2 #58

ddn0 opened this issue Mar 26, 2024 · 3 comments · May be fixed by #67
Labels
enhancement New feature or request

Comments

@ddn0
Copy link
Collaborator

ddn0 commented Mar 26, 2024

It looks like the implementation of CEL matches, just calls Python re.search but Python re is not the same as RE2 as an example \z in RE2 should match the end of text, but \z in Python re is an invalid escape. The equivalent in Python re is \Z but that maps to an unsupported escape in RE2.

Example

echo '""' | python -m celpy 'string(this).matches("^\\z")'
# Should output true, but instead emits the error "re.error: bad escape \z at position 1"
echo '""' | python -m celpy 'string(this).matches("^\\Z")'
# Should be an error as \Z is not supported in RE2, but instead outputs true

Example of another CEL evaluator rejecting \Z but accepting \z

@slott56
Copy link
Collaborator

slott56 commented May 21, 2024

A pull request to replace re with https://pypi.org/project/re2/ would be welcome.

@slott56 slott56 added the enhancement New feature or request label May 21, 2024
@ddn0 ddn0 linked a pull request May 24, 2024 that will close this issue
@ddn0
Copy link
Collaborator Author

ddn0 commented May 24, 2024

A pull request to replace re with https://pypi.org/project/re2/ would be welcome.

Done.

Please let me know what your style and testing preference is. I just made a quick scan of the repo before making my PR.

Also, re2 is a pretty old and looks unmaintained. I opted to use google-re2 instead.

@slott56
Copy link
Collaborator

slott56 commented May 26, 2024

There's a tox.ini to run a complete test suite.

The style is generally done by black.

You can also look at the GitHub workflows to see how the tox.ini runs.

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

Successfully merging a pull request may close this issue.

2 participants