#string-matching #pattern-matching #matching #glob #glob-pattern #string-pattern #star

wildmatch

Simple string matching with single- and multi-character wildcard operator

24 stable releases

2.4.0 Sep 30, 2024
2.3.4 May 22, 2024
2.3.3 Mar 14, 2024
2.3.0 Dec 25, 2023
1.0.6 Mar 3, 2020

#23 in Algorithms

Download history 46660/week @ 2024-09-23 48318/week @ 2024-09-30 55108/week @ 2024-10-07 52882/week @ 2024-10-14 54858/week @ 2024-10-21 53598/week @ 2024-10-28 54326/week @ 2024-11-04 51035/week @ 2024-11-11 55642/week @ 2024-11-18 51783/week @ 2024-11-25 54032/week @ 2024-12-02 52519/week @ 2024-12-09 44356/week @ 2024-12-16 22565/week @ 2024-12-23 22908/week @ 2024-12-30 44962/week @ 2025-01-06

137,791 downloads per month
Used in 410 crates (67 directly)

MIT license

21KB
370 lines

wildmatch

build status docs downloads crate license codecov

Match strings against a simple wildcard pattern. Tests a wildcard pattern p against an input string s. Returns true only when p matches the entirety of s.

See also the example described on wikipedia for matching wildcards.

  • ? matches exactly one occurrence of any character.
  • * matches arbitrary many (including zero) occurrences of any character.
  • No escape characters are defined.

Can also be used with a custom match pattern to define own wildcard patterns for single and multi-character matching.

For example the pattern ca? will match cat or car. The pattern https://* will match all https urls, such as https://google.de or https://github.com/becheran/wildmatch.

The following table shows a performance benchmarks between wildmatch, regex,glob, and the regex_lite libraries:

Benchmark wildmatch regex glob regex_lite
compiling/text 462 ns 39,714 ns 1,470 ns 13,210 ns
compiling/complex 190 ns 153,830 ns 238 ns 60 ns
matching/text 186 ns 4,065 ns 456 ns 6,097 ns
matching/complex 310 ns 16,085 ns 1,426 ns 3,773 ns

The library only depends on the rust stdlib.

See the documentation for usage and more examples.

Dependencies

~155KB