[src]

Struct glob::Pattern

pub struct Pattern {
    // some fields omitted
}

A compiled Unix shell style pattern.

Methods

impl Pattern

fn new(pattern: &str) -> Pattern

This function compiles Unix shell style patterns: ? matches any single character, * matches any (possibly empty) sequence of characters and [...] matches any character inside the brackets, unless the first character is ! in which case it matches any character except those between the ! and the ]. Character sequences can also specify ranges of characters, as ordered by Unicode, so e.g. [0-9] specifies any character between 0 and 9 inclusive.

The metacharacters ?, *, [, ] can be matched by using brackets (e.g. [?]). When a ] occurs immediately following [ or [! then it is interpreted as being part of, rather then ending, the character set, so ] and NOT ] can be matched by []] and [!]] respectively. The - character can be specified inside a character sequence pattern by placing it at the start or the end, e.g. [abc-].

When a [ does not have a closing ] before the end of the string then the [ will be treated literally.

fn escape(s: &str) -> ~str

Escape metacharacters within the given string by surrounding them in brackets. The resulting string will, when compiled into a Pattern, match the input string and nothing else.

fn matches(&self, str: &str) -> bool

Return if the given str matches this Pattern using the default match options (i.e. MatchOptions::new()).

Example

use glob::Pattern;

assert!(Pattern::new("c?t").matches("cat"));
assert!(Pattern::new("k[!e]tteh").matches("kitteh"));
assert!(Pattern::new("d*g").matches("doog"));

fn matches_path(&self, path: &Path) -> bool

Return if the given Path, when converted to a str, matches this Pattern using the default match options (i.e. MatchOptions::new()).

fn matches_with(&self, str: &str, options: MatchOptions) -> bool

Return if the given str matches this Pattern using the specified match options.

fn matches_path_with(&self, path: &Path, options: MatchOptions) -> bool

Return if the given Path, when converted to a str, matches this Pattern using the specified match options.

Trait Implementations

Derived Implementations

impl Default for Pattern

fn default() -> Pattern

impl Hash for Pattern

fn hash(&self, __arg_0: &mut SipState)

impl TotalOrd for Pattern

fn cmp(&self, __arg_0: &Pattern) -> Ordering

impl Ord for Pattern

fn lt(&self, __arg_0: &Pattern) -> bool

fn le(&self, __arg_0: &Pattern) -> bool

fn gt(&self, __arg_0: &Pattern) -> bool

fn ge(&self, __arg_0: &Pattern) -> bool

impl TotalEq for Pattern

fn assert_receiver_is_total_eq(&self)

impl Eq for Pattern

fn eq(&self, __arg_0: &Pattern) -> bool

fn ne(&self, __arg_0: &Pattern) -> bool

impl Clone for Pattern

fn clone(&self) -> Pattern