#string-matching #pattern-matching #matching #star #glob #pattern-match #questionmark

wildmatch

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

22 stable releases

2.3.3 Mar 14, 2024
2.3.0 Dec 25, 2023
2.1.1 Jun 28, 2022
2.1.0 Apr 7, 2021
1.0.6 Mar 3, 2020

#21 in Algorithms

Download history 35031/week @ 2024-01-17 37438/week @ 2024-01-24 34162/week @ 2024-01-31 32108/week @ 2024-02-07 31672/week @ 2024-02-14 33563/week @ 2024-02-21 41133/week @ 2024-02-28 43129/week @ 2024-03-06 43962/week @ 2024-03-13 44042/week @ 2024-03-20 36786/week @ 2024-03-27 41622/week @ 2024-04-03 39789/week @ 2024-04-10 40728/week @ 2024-04-17 40816/week @ 2024-04-24 30425/week @ 2024-05-01

158,702 downloads per month
Used in 369 crates (51 directly)

MIT license

20KB
337 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

~175KB