GlobPattern
ConsoleMonster.Text
A shell-style name pattern such as *.cs, report-??.csv or [a-c]*, for marking rows by pattern. Several patterns are separated with ; or , and match when any of them matches; ! before a pattern excludes what it matches (*.log;!debug*).
Inheritance
- object
- GlobPattern
Remarks
* matches any run of characters, ? one character, [abc] or [a-z] one character from the set and [!abc] one character outside it. A backslash escapes the next character only where it is not a path separator, so Windows paths are never patterns. Matching is linear in the text and never compiles a regular expression.
Constructors
public GlobPattern(string pattern, bool caseSensitive = false) #Creates a pattern.
Parameters
- pattern string
- One or more patterns separated by ; or ,.
- caseSensitive bool = false
- Whether letters must match case exactly; names are compared case-insensitively by default.
Methods
public bool IsMatch(string? text) #Whether a name matches.
Parameters
- text string?
- The name, usually a file name without its folder.
Returns
bool True when an included pattern matches and no excluded one does.public static bool IsMatch(string pattern, string? text, bool caseSensitive = false) #Whether a name matches a pattern; see GlobPattern.
Parameters
- pattern string
- The pattern.
- text string?
- The name.
- caseSensitive bool = false
- Whether letters must match case exactly.
Returns
bool True on a match.public override string ToString() #Returns a string that represents the current object.
Returns
string A string that represents the current object.