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 non-greedy in regex #12095

Open
2 tasks done
ModProg opened this issue Dec 20, 2024 · 1 comment
Open
2 tasks done

Support non-greedy in regex #12095

ModProg opened this issue Dec 20, 2024 · 1 comment
Labels
feature Feature request or proposal

Comments

@ModProg
Copy link

ModProg commented Dec 20, 2024

Is your feature request related to a problem?

When using builtins.match I'd like to be able to do non-greedy matches.

Proposed solution

Add support for ? in combination with e.g. * or +.

Alternative solutions

I could probably use {0,x} where I increase x slowly until I get a match therefor implementing this in nix instead of relying on a regex feature.

Additional context

Checklist


Add 👍 to issues you find important.

@ModProg ModProg added the feature Feature request or proposal label Dec 20, 2024
@ModProg
Copy link
Author

ModProg commented Dec 20, 2024

Example:

❯ nix repl
Nix 2.24.7
Type :? for help.
nix-repl> builtins.match "(.*?)[ab].*" "zab"
[ "za" ]

I would have expected z because .*? should be non greedy

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

No branches or pull requests

1 participant