pub fn from_str(glob: &str) -> Result<Pattern, PatternError>
Expand description

Parse a glob Pattern from a string.

This function amends the input string to replace any caret or circumflex character (^) used to negate a set of characters with an exclamation mark (!), which adapts rust’s glob matching to function the way the GNU utils’ fnmatch does.

Examples

use std::time::Duration;
use uucore::parse_glob::from_str;
assert!(!from_str("[^abc]").unwrap().matches("a"));
assert!(from_str("[^abc]").unwrap().matches("x"));