fuzzymatch

Implements a fuzzy search algorithm, yielding the same results as what the fuzzy match algorithm in VSCode matches. This is basically a fuzzy contains / canFind method for strings and arrays.

However this library does not offer any fuzzy match scoring. This functionality might be added in the future in new methods. The check-only methods are ideal if the result is intended to be passed into other systems that are responsible for display and sorting. (e.g. from DCD / serve-d into VSCode, IDEs or other editors)

It is quite efficient, allocates no memory and works with character ranges as well as simple arrays. Pre-compiled string versions are available for reduced compilation time for simple string/wstring/dstring matches.

This works by going through the search string character by character, on every matching character, the matcher string advances by one character. If the matcher string is completely checked, the fuzzy match returns true.

Methods: - fuzzyMatchesUni - fuzzy contains method with unicode decoding - fuzzyMatchesRaw - fuzzy contains method on arbitrary arrays

Members

Functions

fuzzyMatchesRaw
bool fuzzyMatchesRaw(R1 doesThis, R2 matchThis)

Works like fuzzyMatchesUni, but does not do any UTF decoding, but rather just goes through the arrays element-by-element.

fuzzyMatchesString
bool fuzzyMatchesString(const(char)[] doesThis, const(char)[] matchThis)
bool fuzzyMatchesString(const(wchar)[] doesThis, const(wchar)[] matchThis)
bool fuzzyMatchesString(const(dchar)[] doesThis, const(dchar)[] matchThis)
fuzzyMatchesStringCS
bool fuzzyMatchesStringCS(const(wchar)[] doesThis, const(wchar)[] matchThis)
bool fuzzyMatchesStringCS(const(char)[] doesThis, const(char)[] matchThis)
bool fuzzyMatchesStringCS(const(dchar)[] doesThis, const(dchar)[] matchThis)

Checks if doesThis contains matchThis in a way that a fuzzy search would find it.

fuzzyMatchesUni
bool fuzzyMatchesUni(R1 doesThis, R2 matchThis)

Checks if doesThis contains matchThis in a way that a fuzzy search would find it.

Meta