Show / Hide Table of Contents

Class wildex

Parses and compares wildcard expression.

public class wildex
Remarks

Used in "find" functions. For example in wnd.find to compare window name, class name and program. The "find" function creates a wildex instance (which parses the wildcard expression), then calls wildex.Match for each item (eg window) to compare some its property text.

Examples
//This version does not support wildcard expressions.
Document Find1(string name, string date) {
	return Documents.Find(x => x.Name.Eqi(name) && x.Date.Eqi(date));
}

//This version supports wildcard expressions.
//null-string arguments are not compared.
Document Find2(string name, string date) {
	wildex n = name, d = date; //null if the string is null
	return Documents.Find(x => (n == null || n.Match(x.Name)) && (d == null || d.Match(x.Date)));
}

//Example of calling such function.
//Find item whose name is "example" (case-insensitive) and date starts with "2017-".
var item = x.Find2("example", "2017-*");

Namespace: Au
Assembly: Au.dll
Inheritance
object
wildex

Constructors

Name Description
wildex(string, bool, bool)

Properties

Name Description
IgnoreCase

Is case-insensitive?

MultiArray

Array of wildex variables, one for each part in multi-part text. null if TextType is not Multi (no option m).

Not

Has option n?

RegexNet

Gets the Regex object created from regular expression string. null if TextType is not RegexNet (no option R).

RegexPcre

Returns the regexp object created from regular expression string. null if TextType is not RegexPcre (no option r).

Text

Returns the text or wildcard string. null if TextType is not Text or Wildcard.

TextType

Gets the type of text (wildcard, regex, etc).

Methods

Name Description
Match(string)

Compares a string with the wildcard expression used to create this wildex. Returns true if they match.

ToString()
hasWildcardChars(ReadOnlySpan<char>)

Returns true if string contains wildcard characters: '*', '?'.

Operators

Name Description
implicit operator wildex(string)

Creates new wildex from wildcard expression string. If the string is null, returns null.