[−][src]Enum fancy_regex::Expr
Regular expression AST. This is public for now but may change.
Variants
An empty expression, e.g. the last branch in (a|b|)
Any character, regex .
Fields of Any
newline: bool
Whether it also matches newlines or not
Start of input text
End of input text
Start of a line
End of a line
The string as a literal, e.g. a
Concatenation of multiple expressions, must match in order, e.g. a.
is a concatenation of
the literal a
and .
for any character
Alternative of multiple expressions, one of them must match, e.g. a|b
is an alternative
where either the literal a
or b
must match
Capturing group of expression, e.g. (a.)
matches a
and any character and "captures"
(remembers) the match
LookAround(Box<Expr>, LookAround)
Look-around (e.g. positive/negative look-ahead or look-behind) with an expression, e.g.
(?=a)
means the next character must be a
(but the match is not consumed)
Repeat of an expression, e.g. a*
or a+
or a{1,3}
Fields of Repeat
child: Box<Expr>
The expression that is being repeated
lo: usize
The minimum number of repetitions
hi: usize
The maximum number of repetitions (or usize::MAX
)
greedy: bool
Greedy means as much as possible is matched, e.g. .*b
would match all of abab
.
Non-greedy means as little as possible, e.g. .*?b
would match only ab
in abab
.
Delegate a regex to the regex crate. This is used as a simplification so that we don't have to represent all the expressions in the AST, e.g. character classes.
Fields of Delegate
Backref(usize)
Back reference to a capture group, e.g. \1
in (abc|def)\1
references the captured group
and the whole regex matches either abcabc
or defdef
.
Atomic non-capturing group, e.g. (?>ab|a)
in text that contains ab
will match ab
and
never backtrack and try a
, even if matching fails after the atomic group.
Methods
impl Expr
[src]
pub fn parse(re: &str) -> Result<(Expr, BitSet)>
[src]
Parse the regex and return an expression (AST) and a bit set with the indexes of groups that are referenced by backrefs.
pub fn to_str(&self, buf: &mut String, precedence: u8)
[src]
Convert expression to a regex string in the regex crate's syntax.
Panics
Panics for expressions that are hard, i.e. can not be handled by the regex crate.
Trait Implementations
Auto Trait Implementations
impl Send for Expr
impl Sync for Expr
impl Unpin for Expr
impl UnwindSafe for Expr
impl RefUnwindSafe for Expr
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for 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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
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> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,