Skip to content
ConsoleMonster
Class

FuzzyMatcher

ConsoleMonster.Text

Namespace
ConsoleMonster.Text
Assembly
ConsoleMonster
Modifiers
static

Matches and ranks short search patterns against display text.

Inheritance

  • object
  • FuzzyMatcher

Methods

public static IReadOnlyList<FuzzyResult<T?>> Rank<T>(IEnumerable<T?> items, Func<T?, string> text, string pattern) #

Ranks matching items by score, retaining source order for ties.

Type Parameters

T
The item type.

Parameters

items System.Collections.Generic.IEnumerable<T?> required
The source items.
text System.Func<T?, string> required
Gets searchable text for an item.
pattern string required
The search pattern.

Returns

IReadOnlyList<FuzzyResult<T?>> Matching results in rank order.
public static bool TryMatch(string pattern, string text, out FuzzyMatch? match) #

Attempts to match a pattern against text.

Parameters

pattern string required
Terms separated by whitespace.
text string required
The text to search.
match ConsoleMonster.Text.FuzzyMatch? required
The score and matched positions when successful.

Returns

bool True when all positive terms match and no exclusion term matches.