[][src]Enum regex_syntax::Expr

pub enum Expr {
    Empty,
    Literal {
        chars: Vec<char>,
        casei: bool,
    },
    LiteralBytes {
        bytes: Vec<u8>,
        casei: bool,
    },
    AnyChar,
    AnyCharNoNL,
    AnyByte,
    AnyByteNoNL,
    Class(CharClass),
    ClassBytes(ByteClass),
    StartLine,
    EndLine,
    StartText,
    EndText,
    WordBoundary,
    NotWordBoundary,
    WordBoundaryAscii,
    NotWordBoundaryAscii,
    Group {
        e: Box<Expr>,
        i: Option<usize>,
        name: Option<String>,
    },
    Repeat {
        e: Box<Expr>,
        r: Repeater,
        greedy: bool,
    },
    Concat(Vec<Expr>),
    Alternate(Vec<Expr>),
}

A regular expression abstract syntax tree.

An Expr represents the abstract syntax of a regular expression.

Variants

Empty

An empty regex (which never matches any text).

Literal

A sequence of one or more literal characters to be matched.

Fields of Literal

chars: Vec<char>

The characters.

casei: bool

Whether to match case insensitively.

LiteralBytes

A sequence of one or more literal bytes to be matched.

Fields of LiteralBytes

bytes: Vec<u8>

The bytes.

casei: bool

Whether to match case insensitively.

The interpretation of "case insensitive" in this context is ambiguous since bytes can be arbitrary. However, a good heuristic is to assume that the bytes are ASCII-compatible and do simple ASCII case folding.

AnyChar

Match any character.

AnyCharNoNL

Match any character, excluding new line (0xA).

AnyByte

Match any byte.

AnyByteNoNL

Match any byte, excluding new line (0xA).

Class(CharClass)

A character class.

ClassBytes(ByteClass)

A character class with byte ranges only.

StartLine

Match the start of a line or beginning of input.

EndLine

Match the end of a line or end of input.

StartText

Match the beginning of input.

EndText

Match the end of input.

WordBoundary

Match a word boundary (word character on one side and a non-word character on the other).

NotWordBoundary

Match a position that is not a word boundary (word or non-word characters on both sides).

WordBoundaryAscii

Match an ASCII word boundary.

NotWordBoundaryAscii

Match a position that is not an ASCII word boundary.

Group

A group, possibly non-capturing.

Fields of Group

e: Box<Expr>

The expression inside the group.

i: Option<usize>

The capture index (starting at 1) only for capturing groups.

name: Option<String>

The capture name, only for capturing named groups.

Repeat

A repeat operator (?, *, + or {m,n}).

Fields of Repeat

e: Box<Expr>

The expression to be repeated. Limited to literals, ., classes or grouped expressions.

r: Repeater

The type of repeat operator used.

greedy: bool

Whether the repeat is greedy (match the most) or not (match the least).

Concat(Vec<Expr>)

A concatenation of expressions. Must be matched one after the other.

N.B. A concat expression can only appear at the top-level or immediately inside a group expression.

Alternate(Vec<Expr>)

An alternation of expressions. Only one must match.

N.B. An alternate expression can only appear at the top-level or immediately inside a group expression.

Methods

impl Expr[src]

pub fn parse(s: &str) -> Result<Expr>[src]

Parses a string in a regular expression syntax tree.

This is a convenience method for parsing an expression using the default configuration. To tweak parsing options (such as which flags are enabled by default), use the ExprBuilder type.

pub fn prefixes(&self) -> Literals[src]

Returns a set of literal prefixes extracted from this expression.

pub fn suffixes(&self) -> Literals[src]

Returns a set of literal suffixes extracted from this expression.

pub fn is_anchored_start(&self) -> bool[src]

Returns true if and only if the expression is required to match from the beginning of text.

pub fn has_anchored_start(&self) -> bool[src]

Returns true if and only if the expression has at least one matchable sub-expression that must match the beginning of text.

pub fn is_anchored_end(&self) -> bool[src]

Returns true if and only if the expression is required to match at the end of the text.

pub fn has_anchored_end(&self) -> bool[src]

Returns true if and only if the expression has at least one matchable sub-expression that must match the beginning of text.

pub fn has_bytes(&self) -> bool[src]

Returns true if and only if the expression contains sub-expressions that can match arbitrary bytes.

Trait Implementations

impl Clone for Expr[src]

impl Eq for Expr[src]

impl PartialEq<Expr> for Expr[src]

impl Display for Expr[src]

This implementation of Display will write a regular expression from the syntax tree. It does not write the original string parsed.

impl Debug for Expr[src]

impl StructuralPartialEq for Expr[src]

impl StructuralEq for Expr[src]

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]

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

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.

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.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]