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

Extending globbing patterns #49

Open
dazinator opened this issue Aug 10, 2018 · 2 comments
Open

Extending globbing patterns #49

dazinator opened this issue Aug 10, 2018 · 2 comments

Comments

@dazinator
Copy link
Owner

dazinator commented Aug 10, 2018

This is a new feature to add support for a set of extended globbing patterns - documented here:

https://www.linuxjournal.com/content/bash-extended-globbing

I see this as an opt-in feature - so I'll add another property on the options class, so you can opt-in like so:

GlobParseOptions.Default.Evaluation.EnableExtendedPatterns = true;

Once enabled, you can use the following additional patterns as supported by bash:

?(pattern-list) Matches zero or one occurrence of the given patterns
*(pattern-list) Matches zero or more occurrences of the given patterns
+(pattern-list) Matches one or more occurrences of the given patterns
@(pattern-list) Matches one of the given patterns
!(pattern-list) Matches anything except one of the given patterns

Here a pattern-list is a list of items separated by a vertical bar "|" (aka the pipe symbol).

For example, the following pattern would match all the JPEG and GIF files that start with either "ab" or "def":

+(ab|def)*+(.jpg|.gif)
@xt0rted
Copy link

xt0rted commented May 15, 2022

Just tried to use this feature and realized it's not yet supported. It'd be a great addition to https://github.com/xt0rted/dotnet-rimraf. Has there been any progress on it? I wanted to adjust my pattern of **/bin to exclude the node_modules folder, or just include the src and test folders, but for now I switched it to ./src/**/bin etc. which also works.

@dazinator
Copy link
Owner Author

@xt0rted - thanks for the feedback on this. I'd really like to add this feature but I've not found time to do any work on it yet so it remains on the backlog. I think perhaps one rainy day I can do some work on adding this. I am glad you found a workaround in the meantime.

I am just thinking off the top of my head about how i might implement such a feature and my first thought was akin to boolean algebra where I might "join" multiple globs - so basically these examples would parse to a "glob of globs" - basically a composite. I plan to play with this idea soon and hopefully go from there. Will update here if I do make progress. If anyone has specific suggestions or wants to make a contribution I am also all ears :-)

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

No branches or pull requests

2 participants