3 releases (breaking)

0.2.0 Jul 9, 2024
0.1.0 Jul 3, 2024
0.0.0-pre May 24, 2024

#90 in Text processing

Download history 99/week @ 2024-05-21 4/week @ 2024-05-28 2/week @ 2024-06-04 252/week @ 2024-07-02 291/week @ 2024-07-09 1903/week @ 2024-07-16 3425/week @ 2024-07-23 3132/week @ 2024-07-30 3006/week @ 2024-08-06 3156/week @ 2024-08-13 2961/week @ 2024-08-20 4095/week @ 2024-08-27 2847/week @ 2024-09-03

13,782 downloads per month

Apache-2.0

54KB
1K SLoC

Build Status Dependency status crates.io Downloads Github stars Documentation License

wildcard

wildcard is a rust crate for wildcard matching.

Here's how to use it:

let wildcard = Wildcard::new("*foo?*bar".as_bytes()).unwrap();

assert!(wildcard.is_match("fooofooobar".as_bytes()));

Special characters can be escaped to represent their literal symbol:

let wildcard = Wildcard::new(r"\*\?".as_bytes()).unwrap();

assert!(!wildcard.is_match("ab".as_bytes()));
assert!(wildcard.is_match("*?".as_bytes()));

You can also capture the substring that matched the metasymbols of the wildcard:

let wildcard = Wildcard::new("* is a * style?".as_bytes()).unwrap();

let captures: Vec<&[u8]> = wildcard.captures("Lambic is a beer style!".as_bytes()).unwrap();

assert_eq!(captures, ["Lambic".as_bytes(), "beer".as_bytes(), "!".as_bytes()]);

Matching customization

With wildcard you can configure these properties of a wildcard:

  1. Configure the symbols for the metasymbols * and ? as well as the escape symbol.
  2. Support for the metasymbol ? can be disabled.
  3. Support for escaping can be disabled.
  4. Support for case-insensitive matching.

Dependencies

~240–680KB
~16K SLoC