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

wildmatch

Simple string matching with questionmark and star wildcard operator

16 stable releases

2.1.0 Apr 7, 2021
2.0.0 Mar 15, 2021
1.1.0 Mar 7, 2021
1.0.12 Oct 24, 2020
1.0.6 Mar 3, 2020

#48 in Algorithms

Download history 2909/week @ 2020-12-25 5952/week @ 2021-01-01 6465/week @ 2021-01-08 6651/week @ 2021-01-15 7939/week @ 2021-01-22 8607/week @ 2021-01-29 8989/week @ 2021-02-05 10055/week @ 2021-02-12 9829/week @ 2021-02-19 8351/week @ 2021-02-26 8888/week @ 2021-03-05 8532/week @ 2021-03-12 10620/week @ 2021-03-19 11404/week @ 2021-03-26 10749/week @ 2021-04-02 11404/week @ 2021-04-09

37,984 downloads per month
Used in 64 crates (15 directly)

MIT license

13KB
241 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