aspnet/FileSystem

Support '?' to match single character in globbing pattern

natemcmaster opened this issue · 4 comments

Syntax: The ? wildcard character matches a single character.

This would allow us to use globbing to match MSBuild wildcard syntax (see https://msdn.microsoft.com/en-us/library/ms171453.aspx#Anchor_3).

Example scenario: creating a file watcher for an MSBuild file....maybe.

I ended up writing a small globbing library in the end, as the pattern matching stuff currently available in asp.net core didn't implement enough of the globbing spec for my needs.

It handles the following syntax (examples sourced
from wikipedia:

Wildcard Description Example Matches Does not match
* matches any number of any characters including none Law* Law, Laws, or Lawyer
? matches any single character ?at Cat, cat, Bat or bat at
[abc] matches one character given in the bracket [CB]at Cat or Bat cat or bat
[a-z] matches one character from the range given in the bracket Letter[0-9] Letter0, Letter1, Letter2 up to Letter9 Letters, Letter or Letter10
[!abc] matches one character that is not given in the bracket [!C]at Bat, bat, or cat Cat
[!a-z] matches one character that is not from the range given in the bracket Letter[!3-5] Letter1, Letter2, Letter6 up to Letter9 and Letterx etc. Letter3, Letter4, Letter5 or Letterxx

Just posting on the off chance someone will find that useful.

are there plans to support standard globbing patterns?

We'd accept PRs for this.

This issue was moved to aspnet/Home#2550