Enum fancy_regex::Expr[][src]

pub enum Expr {
Show variants Empty, Any { newline: bool, }, StartText, EndText, StartLine, EndLine, Literal { val: String, casei: bool, }, Concat(Vec<Expr>), Alt(Vec<Expr>), Group(Box<Expr>), LookAround(Box<Expr>, LookAround), Repeat { child: Box<Expr>, lo: usize, hi: usize, greedy: bool, }, Delegate { inner: String, size: usize, casei: bool, }, Backref(usize), NamedBackref(String), AtomicGroup(Box<Expr>),
}
Expand description

Regular expression AST. This is public for now but may change.

Variants

Empty
Expand description

An empty expression, e.g. the last branch in (a|b|)

Any
Expand description

Any character, regex .

Show fields

Fields of Any

newline: bool
Expand description

Whether it also matches newlines or not

StartText
Expand description

Start of input text

EndText
Expand description

End of input text

StartLine
Expand description

Start of a line

EndLine
Expand description

End of a line

Literal
Expand description

The string as a literal, e.g. a

Show fields

Fields of Literal

val: String
Expand description

The string to match

casei: bool
Expand description

Whether match is case-insensitive or not

Concat(Vec<Expr>)
Expand description

Concatenation of multiple expressions, must match in order, e.g. a. is a concatenation of the literal a and . for any character

Alt(Vec<Expr>)
Expand description

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

Group(Box<Expr>)
Expand description

Capturing group of expression, e.g. (a.) matches a and any character and “captures” (remembers) the match

LookAround(Box<Expr>, LookAround)
Expand description

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
Expand description

Repeat of an expression, e.g. a* or a+ or a{1,3}

Show fields

Fields of Repeat

child: Box<Expr>
Expand description

The expression that is being repeated

lo: usize
Expand description

The minimum number of repetitions

hi: usize
Expand description

The maximum number of repetitions (or usize::MAX)

greedy: bool
Expand description

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
Expand description

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.

Show fields

Fields of Delegate

inner: String
Expand description

The regex

size: usize
Expand description

How many characters the regex matches

casei: bool
Expand description

Whether the matching is case-insensitive or not

Backref(usize)
Expand description

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.

NamedBackref(String)
Expand description

Back reference to a named capture group.

AtomicGroup(Box<Expr>)
Expand description

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.

Implementations

impl Expr[src]

pub fn parse_tree(re: &str) -> Result<ExprTree>[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

impl Debug for Expr[src]

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

Formats the value using the given formatter. Read more

impl PartialEq<Expr> for Expr[src]

fn eq(&self, other: &Expr) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, other: &Expr) -> bool[src]

This method tests for !=.

impl Eq for Expr[src]

impl StructuralEq for Expr[src]

impl StructuralPartialEq for Expr[src]

Auto Trait Implementations

impl RefUnwindSafe for Expr

impl Send for Expr

impl Sync for Expr

impl Unpin for Expr

impl UnwindSafe for Expr

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, 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.