#matching #star #string-matching #globbing #questionmark

wildmatch

Simple string matching with questionmark and star wildcard operator

17 stable releases

2.1.1 Jun 28, 2022
2.1.0 Apr 7, 2021
2.0.0 Mar 15, 2021
1.1.0 Mar 7, 2021
1.0.6 Mar 3, 2020

#26 in Algorithms

Download history 27233/week @ 2023-02-16 29930/week @ 2023-02-23 28398/week @ 2023-03-02 29976/week @ 2023-03-09 29002/week @ 2023-03-16 27631/week @ 2023-03-23 26677/week @ 2023-03-30 22224/week @ 2023-04-06 23715/week @ 2023-04-13 22894/week @ 2023-04-20 21940/week @ 2023-04-27 23419/week @ 2023-05-04 23627/week @ 2023-05-11 22131/week @ 2023-05-18 22033/week @ 2023-05-25 28370/week @ 2023-06-01

100,755 downloads per month
Used in 153 crates (34 directly)

MIT license

16KB
297 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.

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.

Compared to the rust regex library, wildmatch pattern compile much faster and match with about the same speed. Compared to glob pattern wildmtach is faster in both compile and match time:

Benchmark wildmatch regex glob
compiling/text 990 ns 476,980 ns 4,517 ns
compiling/complex 122 ns 177,510 ns 562 ns
matching/text 568 ns 655 ns 1,896 ns
matching/complex 664 ns 575 ns 4,208 ns

The library only depends on the rust stdlib.

See the documentation for usage and more examples.

No runtime deps