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

Switch from re to 3rd-party regex module #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Seirdy
Copy link

@Seirdy Seirdy commented Nov 9, 2020

Switch to the more featureful, API-compatible regex module. This module
is recommended for more advanced regular expressions in Python's own
documentation: https://docs.python.org/3/library/re.html

Regex patterns can now use features such as variable-length lookarounds,
lookarounds in conditional patterns, recursive patterns, fuzzy matching,
\m and \M for the start/end of a word, and many others. See
https://pypi.org/project/regex/ for more information.

Switch to the more featureful, API-compatible regex module. This module
is recommended for more advanced regular expressions in Python's own
documentation: https://docs.python.org/3/library/re.html

Regex patterns can now use features such as variable-length lookarounds,
lookarounds in conditional patterns, recursive patterns, fuzzy matching,
\m and \M for the start/end of a word, and many others. See
https://pypi.org/project/regex/ for more information.
@Seirdy
Copy link
Author

Seirdy commented Nov 9, 2020

My rationale for introducing a third-party dependency like this is that none of the existing find-replace solutions I’ve tried support anything close to the advanced featureset of regex. On the commandline, between https://github.com/chmln/sd, ripgrep with rg --engine=pcre2 --passthru <find> -r <replace>, and some others, subst could become the most advanced CLI for regex substitution out there just by changing import re to import regex as re.

@msztolcman
Copy link
Owner

First: thanks for an idea and PR!
I find the idea great, and would be also great to merge it, but there are usecases where installing dependencies out of stdlib are a pain. However, most of the ones I know, relates to install subst without pip, just by download raw file and us it as is.

Please, handle this situation (should be enough to try import regex, and if fails - use re instead).
Also - please update pipenv dependencies. Should be enough to initialize virtualenv (pipenv install --dev), then install new dependency (pipenv install regex).

Would you like to update your PR for this stuff?

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

Successfully merging this pull request may close these issues.

2 participants