Struct regress::Regex[][src]

pub struct Regex { /* fields omitted */ }
Expand description

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]

fn clone(&self) -> Regex[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for Regex[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl FromStr for Regex[src]

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

Attempts to parse a string into a regular expression

type Err = Error

The associated error which can be returned from parsing.

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]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

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

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

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

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

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

pub fn from(t: T) -> T[src]

Performs the conversion.

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

pub fn into(self) -> U[src]

Performs the conversion.

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

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

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.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

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.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.