Crate wildmatch[][src]

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.

No escape characters are defined.

  • ? matches exactly one occurrence of any character.
  • * matches arbitrary many (including zero) occurrences of any character.

Examples matching wildcards:

assert!(WildMatch::new("cat").matches("cat"));
assert!(WildMatch::new("*cat*").matches("dog_cat_dog"));
assert!(WildMatch::new("c?t").matches("cat"));
assert!(WildMatch::new("c?t").matches("cot"));

Examples not matching wildcards:

assert!(!WildMatch::new("dog").matches("cat"));
assert!(!WildMatch::new("*d").matches("cat"));
assert!(!WildMatch::new("????").matches("cat"));
assert!(!WildMatch::new("?").matches("cat"));

Structs

WildMatch

Wildcard matcher used to match strings.