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

enhance apply_regex_substitutions #4758

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

Conversation

Flamefire
Copy link
Contributor

@Flamefire Flamefire commented Feb 7, 2025

It might be required to replace patterns with more context, e.g. content of the next or previous line to disambiguate otherwise too generic matches.

Add parameter single_line to enable the old behavior (default) of matching per line and otherwise match the whole text.

Add parameter match_all to require all patterns to match for each file not only at least one.

Also allow to pass regex Pattern object instead of string patterns to allow for additional flags per pattern.
Additionally I collect all error messages for all files and report them together instead of per file for easier resolving.

Note: I set the defaults to be backwards compatible to the current behavior. For EB 5 I'd change match_all to default to True which is likely the safer default.

@Flamefire Flamefire force-pushed the multi-line-replacement branch from c14b549 to 20826c6 Compare February 7, 2025 10:13
It might be required to replace patterns with more context, e.g. content
of the next or previous line to disambiguate otherwise too generic matches.

Add parameter `single_line` to enable the old behavior (default) of
matching per line and otherwise match the whole text.
Add parameter `match_all` to require all patterns to match for each file
not only at least one.
@Flamefire Flamefire force-pushed the multi-line-replacement branch from 20826c6 to 981e820 Compare February 7, 2025 11:09
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.

1 participant