pub struct Pattern { priv tokens: ~[PatternToken], }
A compiled Unix shell style pattern.
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()
).
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: &std::path::PosixPath) -> 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: &std::path::PosixPath, options: MatchOptions) -> bool
Return if the given Path
, when converted to a str
, matches this Pattern
using the specified match options.
impl std::clone::Clone for Pattern
fn clone(&self) -> Pattern
impl std::cmp::Eq for Pattern
impl std::cmp::TotalEq for Pattern
fn equals(&self, __arg_0: &Pattern) -> bool
impl std::cmp::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 std::cmp::TotalOrd for Pattern
fn cmp(&self, __arg_0: &Pattern) -> std::cmp::Ordering
impl std::to_bytes::IterBytes for Pattern
fn iter_bytes(&self, __arg_0: bool, __arg_1: std::to_bytes::Cb) -> bool
impl std::default::Default for Pattern
fn default() -> Pattern
Prefix searches with a type followed by a colon (e.g.
fn:
) to restrict the search to a given type.
Accepted types are: fn
, mod
,
struct
(or str
), enum
,
trait
, typedef
(or
tdef
).