You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can also use the `GlobBuilder` class if you wish to build up a glob using a fluent syntax.
@@ -91,9 +66,50 @@ In addition, DotNet Glob also supports:
91
66
|`**`| matches any number of path / directory segments. When used must be the only contents of a segment. | /\*\*/some.\*| /foo/bar/bah/some.txt, /some.txt, or /foo/some.txt |
92
67
93
68
69
+
# Advanced Usages
70
+
71
+
## Parsing options.
72
+
By default, when your glob pattern is parsed, `DotNet.Glob` will only allow literals which are valid for path / directory names.
This is optimised for matching against paths / directory strings.
79
+
However, introduced in version `1.6.4`, you can override this behaviour so that you can include arbitrary characters in your literals. For example, here is a pattern that matches the literal `"Stuff`:
80
+
81
+
```csharp
82
+
// Overide the default options globally for all matche:
- Letter Ranges. Any letter range (i.e '[A-Z]') will now match both lower or upper case characters.
110
+
- Character Lists. Any character list (i.e '[ABC]') will now match both lower or upper case characters.
111
+
- Literals. Any literal (i.e 'foo') will now match both lower or upper case characters i.e `FoO` will match `foO` etc.
95
112
96
-
# Advanced Usages
97
113
98
114
## Match Generation
99
115
Given a glob, you can generate random matches, or non matches, for that glob.
@@ -117,16 +133,3 @@ For example, given the glob pattern `/f?o/bar/**/*.txt` you could generate match
117
133
}
118
134
119
135
```
120
-
121
-
122
-
## Match Analysis
123
-
124
-
The `IsMatch` method just returns you a boolean. If you require more in-depth information about the match including which tokens were matched, or failed to match, you can do this:
125
-
126
-
```
127
-
MatchInfo match = glob.Match(somestring);
128
-
129
-
```
130
-
131
-
You can then inspect the `MatchInfo` which holds all of those useful details.
Copy file name to clipboardExpand all lines: src/DotNet.Glob.Tests/GlobTests.cs
+31-10Lines changed: 31 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -21,9 +21,15 @@ public class GlobTests
21
21
[InlineData("C:\\name\\**",false,"C:\\name.ext","C:\\name_longer.ext")]// Regression Test for https://github.com/dazinator/DotNet.Glob/issues/29
22
22
[InlineData("Bumpy/**/AssemblyInfo.cs",false,"Bumpy.Test/Properties/AssemblyInfo.cs")]// Regression Test for https://github.com/dazinator/DotNet.Glob/issues/33
23
23
[InlineData("C:\\sources\\x-y 1\\BIN\\DEBUG\\COMPILE\\**\\MSVC*120.DLL",false,"C:\\sources\\x-y 1\\BIN\\DEBUG\\COMPILE\\ANTLR3.RUNTIME.DLL")]// Attempted repro for https://github.com/dazinator/DotNet.Glob/issues/37
24
+
[InlineData("literal1",false,"LITERAL1")]// Regression tests for https://github.com/dazinator/DotNet.Glob/issues/41
25
+
[InlineData("*ral*",false,"LITERAL1")]// Regression tests for https://github.com/dazinator/DotNet.Glob/issues/41
26
+
[InlineData("[list]s",false,"LS","iS","Is")]// Regression tests for https://github.com/dazinator/DotNet.Glob/issues/41
27
+
[InlineData("range/[a-b][C-D]",false,"range/ac","range/Ad","range/BD")]// Regression tests for https://github.com/dazinator/DotNet.Glob/issues/41
0 commit comments