Struct regress::Regex [−][src]
pub struct Regex { /* fields omitted */ }
Expand description
A Regex is the compiled version of a pattern.
Implementations
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.
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:
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
.
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));
Searches text
to find the first match.
The input text is expected to be ascii-only: only ASCII case-folding is
supported.
Searches text
, returning an iterator over non-overlapping matches.
The input text is expected to be ascii-only: only ASCII case-folding is
supported.
Returns an iterator for matches found in ‘text’ starting at byte index
start
.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Regex
impl UnwindSafe for Regex
Blanket Implementations
Mutably borrows from an owned value. Read more