#string-matching #globbing #star #questionmark

wildmatch

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

27 stable releases

2.6.1 Nov 14, 2025
2.5.0 Sep 12, 2025
2.4.0 Sep 30, 2024
2.3.4 May 22, 2024
1.0.6 Mar 3, 2020

#24 in Algorithms

Download history 120293/week @ 2025-10-29 116485/week @ 2025-11-05 116633/week @ 2025-11-12 160285/week @ 2025-11-19 99083/week @ 2025-11-26 132920/week @ 2025-12-03 131613/week @ 2025-12-10 110490/week @ 2025-12-17 61544/week @ 2025-12-24 73113/week @ 2025-12-31 133110/week @ 2026-01-07 114317/week @ 2026-01-14 133274/week @ 2026-01-21 141288/week @ 2026-01-28 204763/week @ 2026-02-04 198216/week @ 2026-02-11

701,696 downloads per month
Used in 500 crates (84 directly)

MIT license

23KB
382 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