Table of Contents

Class WildcardPattern

Namespace
Acuit.Pinpoint.Common
Assembly
Acuit.Pinpoint.Common.dll

Represents a wildcard pattern that can be used to match strings.

[Obsolete("This is deprecated and will be removed in a future version; Acuit.Pinpoint.WildcardExpressions.WildcardExpression should be used instead.")]
public class WildcardPattern
Inheritance
WildcardPattern
Inherited Members

Remarks

The following wildcards are supported:

  • = zero or more characters; ? = any one character; [AB] = one character from a set; [0-9] = one character from a range; [0-9ABCDEF] = combination of the above; \ = treat the next character as a literal; ALT1|ALT2 = two alternatives for the overall string; (ALT1|ALT2) = two alternatives within the overall string All comparisons are done without regard to case. If the wildcard pattern is surrounded by '/' character at the beginning and end, then the pattern is assumed to be a regular expression.

Constructors

WildcardPattern(string)

Initializes a new instance of the WildcardPattern class.

public WildcardPattern(string pattern)

Parameters

pattern string

The wildcard pattern.

Exceptions

ArgumentNullException

pattern is null.

ArgumentException

The wildcard pattern is not valid.

WildcardPattern(string, bool)

Initializes a new instance of the WildcardPattern class.

public WildcardPattern(string pattern, bool convertCaptures)

Parameters

pattern string

The wildcard pattern.

convertCaptures bool

Whether to use "{name}"-style captures.

Exceptions

ArgumentNullException

pattern is null.

ArgumentException

The wildcard pattern is not valid.

Properties

MatchAlways

Gets a WildcardPattern that always matches any input string.

public static WildcardPattern MatchAlways { get; }

Property Value

WildcardPattern

MatchNever

Gets a WildcardPattern that never matches any input string.

public static WildcardPattern MatchNever { get; }

Property Value

WildcardPattern

Pattern

Gets the wildcard pattern.

public string Pattern { get; }

Property Value

string

RegexPattern

Gets the regular expression equivalent for the wildcard pattern.

public string RegexPattern { get; }

Property Value

string

Methods

ConvertToRegexPattern(string)

Converts a wildcard pattern to the equivalent regular expression pattern.

public static string ConvertToRegexPattern(string pattern)

Parameters

pattern string

The wildcard pattern to convert.

Returns

string

Returns the equivalent regular expression pattern.

Exceptions

ArgumentNullException

pattern is null.

ArgumentException

The wildcard pattern is not valid.

ConvertToRegexPattern(string, bool)

Converts a wildcard pattern to the equivalent regular expression pattern.

public static string ConvertToRegexPattern(string pattern, bool convertCaptures)

Parameters

pattern string

The wildcard pattern to convert.

convertCaptures bool

Whether to convert "{name}"-style captures.

Returns

string

Returns the equivalent regular expression pattern.

Remarks

If the wildcard pattern starts and ends with '/' characters, then the pattern in between is assumed to already be a regular expression.

Exceptions

ArgumentNullException

pattern is null.

ArgumentException

The wildcard pattern is not valid.

IsMatch(string)

Determines whether input text matches the wildcard pattern.

public bool IsMatch(string text)

Parameters

text string

The input text.

Returns

bool

Returns true if the input text matches the wildcard pattern.