Crate yash_fnmatch
source ·Expand description
This crate provides the fnmatch
function that performs pattern matching
based on a globbing pattern.
This implementation supports the following syntax in patterns:
- Any single character (
?
) - Any character sequence (
*
) - Bracket expression (
[...]
)- Character literals
- Character ranges (e.g.
a-z
) - Complement (
[!...]
) - Collating symbols (e.g.
[.ch.]
) - Equivalence classes (e.g.
[=a=]
) - Character classes (e.g.
[:alpha:]
)
The current implementation does not support any locale-specific characteristics. Especially, collating symbols and equivalent classes only match the specified character sequence itself, and character classes only match ASCII characters.
This crate is very similar to the fnmatch-regex
crate in that both
perform matching by converting the pattern to a regular expression. The
yash-fnmatch
crate tries to support the POSIX specification as much as
possible rather than introducing unique (non-portable) functionalities.
§Example
use yash_fnmatch::{Pattern, without_escape};
let p = Pattern::parse(without_escape("r*g")).unwrap();
assert_eq!(p.find("string"), Some(2..6));
Modules§
- Abstract syntax tree for globbing patterns
Structs§
- Configuration for a pattern
- Compiled globbing pattern
- Iterator returned by
with_escape
- Iterator returned by
without_escape
Enums§
- Error that may happen in building a pattern.
- Character appearing in patterns
Functions§
- Adapts an escaped string for input to a parser.
- Adapts a literal string for input to a parser.