Skip to content

WildcardMatch

JaykeBird edited this page Feb 21, 2023 · 5 revisions

Back to home | Back to Reference | View raw text

WildcardMatch class

Description

A class that can match a string against a given target string with wildcards (i.e. "d*g" can match "dig" or "dog" or "ding").

Diagram

  flowchart LR
  classDef interfaceStyle stroke-dasharray: 5 5;
  classDef abstractStyle stroke-width:4px
  subgraph SolidShineUi
  SolidShineUi.WildcardMatch[[WildcardMatch]]
  end
Loading

Members

Methods

Public Static methods

Returns Name
bool MatchesWildcard(...)
Match a string against a given target string with wildcards ("*" and "?" are supported). See Remarks for more details.

Details

Summary

A class that can match a string against a given target string with wildcards (i.e. "d*g" can match "dig" or "dog" or "ding").

Methods

MatchesWildcard [1/2]

public static bool MatchesWildcard(string text, string wildcardString)
Arguments
Type Name Description
string text The string to test.
string wildcardString The string to match against, containing the wildcards.
Summary

Match a string against a given target string with wildcards ("*" and "?" are supported). See Remarks for more details.

Remarks

This function can match a string against a wildcard string. Wildcards are used, for example, in Windows's file dialogs for file filters, as well as other places in Windows or MS-DOS where one or more files can be interacted with. Supported wildcard characters are "", which matches any number of characters, and "?", which matches just one character. (For example, "dg" will match both "dig" and "ding", where as "d?g" will only match "dig", and not "ding" or "dg".) Regex (regular expressions) is a lot more powerful than what wildcards alone can provide, but regex strings can also be a lot more complicated to decipher.

This class was written by H.A. Sullivan.

Returns

True if it can be matched; false if they cannot be.

MatchesWildcard [2/2]

public static bool MatchesWildcard(string text, string wildcardString, bool ignoreCase)
Arguments
Type Name Description
string text The string to test.
string wildcardString The string to match against, containing the wildcards.
bool ignoreCase Set if letter casing is ignored while matching.
Summary

Match a string against a given target string with wildcards ("*" and "?" are supported). See Remarks for details.

Remarks

This function can match a string against a wildcard string. Wildcards are used, for example, in Windows's file dialogs for file filters, as well as other places in Windows or MS-DOS where one or more files can be interacted with. Supported wildcard characters are "", which matches any number of characters, and "?", which matches just one character. (For example, "dg" will match both "dig" and "ding", where as "d?g" will only match "dig", and not "ding" or "dg".) Regex (regular expressions) is a lot more powerful than what wildcards alone can provide, but regex strings can also be a lot more complicated to decipher.

This class was written by H.A. Sullivan.

Returns

True if it can be matched; false if they cannot be.

Generated with ModularDoc

Clone this wiki locally