Struct regress::Regex [−][src]
pub struct Regex { /* fields omitted */ }
Expand description
A Regex is the compiled version of a pattern.
Implementations
impl Regex
[src]
impl Regex
[src]pub fn new(pattern: &str) -> Result<Regex, Error>
[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]
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_iter<'r, 't>(&'r self, text: &'t str) -> Matches<'r, 't>
[src]
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]
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]
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]
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]
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
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> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
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]
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