DotNet.Glob icon indicating copy to clipboard operation
DotNet.Glob copied to clipboard

Extending globbing patterns

Open dazinator opened this issue 5 years ago • 2 comments

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)

dazinator avatar Aug 10 '18 00:08 dazinator

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.

xt0rted avatar May 15 '22 18:05 xt0rted

@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 :-)

dazinator avatar May 15 '22 22:05 dazinator