[][src]Struct regress::Regex

pub struct Regex { /* fields omitted */ }

A Regex is the compiled version of a pattern.

Implementations

impl Regex[src]

pub fn new(pattern: &str) -> Result<Regex, Error>[src]

Construct a regex by parsing pattern using the default flags. An Error may be returned if the syntax is invalid. Note that this is rather expensive; prefer to cache a Regex which is intended to be used more than once.

pub fn with_flags<F>(pattern: &str, flags: F) -> Result<Regex, Error> where
    F: Into<Flags>, 
[src]

Construct a regex by parsing pattern with flags. An Error may be returned if the syntax is invalid. Note it is preferable to cache a Regex which is intended to be used more than once, as the parse may be expensive. For example:

pub fn find(&self, text: &str) -> Option<Match>[src]

Searches text to find the first match.

pub fn find_iter<'r, 't>(&'r self, text: &'t str) -> Matches<'r, 't>[src]

Searches text, returning an iterator over non-overlapping matches. Note that the resulting Iterator borrows both the regex 'r and the input string as 't.

pub fn find_from<'r, 't>(
    &'r self,
    text: &'t str,
    start: usize
) -> Matches<'r, 't>
[src]

Returns an iterator for matches found in 'text' starting at byte index start. Note this may be different from passing a sliced text in the case of lookbehind assertions. Example:

 use regress::Regex;
 let text = "xyxy";
 let re = Regex::new(r"(?<=x)y").unwrap();
 let t1 = re.find(&text[1..]).unwrap().range();
 assert!(t1 == (2..3));
 let t2 = re.find_from(text, 1).next().unwrap().range();
 assert!(t2 == (1..2));

pub fn find_ascii(&self, text: &str) -> Option<Match>[src]

Searches text to find the first match. The input text is expected to be ascii-only: only ASCII case-folding is supported.

pub fn find_iter_ascii<'r, 't>(&'r self, text: &'t str) -> AsciiMatches<'r, 't>[src]

Searches text, returning an iterator over non-overlapping matches. The input text is expected to be ascii-only: only ASCII case-folding is supported.

pub fn find_from_ascii<'r, 't>(
    &'r self,
    text: &'t str,
    start: usize
) -> AsciiMatches<'r, 't>
[src]

Returns an iterator for matches found in 'text' starting at byte index start.

Trait Implementations

impl Clone for Regex[src]

impl Debug for Regex[src]

impl FromStr for Regex[src]

type Err = Error

The associated error which can be returned from parsing.

fn from_str(s: &str) -> Result<Self, Error>[src]

Attempts to parse a string into a regular expression

Auto Trait Implementations

impl RefUnwindSafe for Regex

impl Send for Regex

impl Sync for Regex

impl Unpin for Regex

impl UnwindSafe for Regex

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.