[−][src]Struct regress::Regex
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 newf(pattern: &str, flags: Flags) -> Result<Regex, Error>
[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]
&'r self,
text: &'t str,
start: usize
) -> Matches<'r, 't>
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().total(); assert!(t1 == (2..3)); let t2 = re.find_from(text, 1).next().unwrap().total(); 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]
&'r self,
text: &'t str,
start: usize
) -> AsciiMatches<'r, 't>
Returns an iterator for matches found in 'text' starting at byte index
start
.
Trait Implementations
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,