Krauss wildcard-matching algorithm explained

In computer science, the Krauss wildcard-matching algorithm is a pattern matching algorithm. Based on the wildcard syntax in common use, e.g. in the Microsoft Windows command-line interface, the algorithm provides a non-recursive mechanism for matching patterns in software applications, based on syntax simpler than that typically offered by regular expressions.

History

The algorithm is based on a history of development, correctness and performance testing, and programmer feedback that began with an unsuccessful search for a reliable non-recursive algorithm for matching wildcards. An initial algorithm, implemented in a single while loop, quickly prompted comments from software developers, leading to improvements.[1] Ongoing comments and suggestions[2] [3] culminated in a revised algorithm still implemented in a single while loop but refined based on a collection of test cases and a performance profiler.[4] The experience tuning the single while loop using the profiler prompted development of a two-loop strategy that achieved further performance gains, particularly in situations involving empty input strings or input containing no wildcard characters.[5] The two-loop algorithm is available for use by the open-source software development community, under the terms of the Apache License v. 2.0, and is accompanied by test case code.

Usage

The algorithm made available under the Apache license is implemented in both pointer-based C++ and portable C++ (implemented without pointers). The test case code, also available under the Apache license, can be applied to any algorithm that provides the pattern matching operations below. The implementation as coded is unable to handle multibyte character sets and poses problems when the text being searched may contain multiple incompatible character sets.

Pattern matching operations

The algorithm supports three pattern matching operations:

Examples

Applications

The original algorithm has been ported to the DataFlex programming language by Larry Heiges[6] for use with Data Access Worldwide code library. It has been posted on GitHub in modified form as part of a log file reader.[7] The 2014 algorithm is part of the Unreal Model Viewer built into the Epic Games Unreal Engine game engine.[8] [9]

See also

Notes and References

  1. Krauss. Kirk. Matching Wildcards: An Algorithm. Dr. Dobb's Journal. 2008.
  2. Web site: wild card searching. alt.os.development. 2008.
  3. Web site: T.J.. wild card matching in text string. 2014. Stack Overflow.
  4. Krauss. Kirk. Matching Wildcards: An Empirical Way to Tame an Algorithm. Dr. Dobb's Journal. 2014.
  5. Web site: Krauss. Kirk. Matching Wildcards: An Improved Algorithm for Big Data. Develop for Performance. 2018.
  6. Web site: Data Access Worldwide Code Library. Heiges. Larry. Text compare function - generalTextCompare.txt. 2008.
  7. Web site: Deniskore. Popular repositories. Deniskore/wildcard/CLogReader.cpp. GitHub. 2013. Lines 173-279.
  8. Web site: gildor2. Unreal Engine Model Viewer (UE Viewer). UModel/Core/Core.cpp. GitHub. 2016. Lines 334-435.
  9. Web site: gildor2. Unreal Engine Model Viewer (UE Viewer). History for UModel/Core/Core.cpp. 2016.