Enum regex_syntax::Expr [] [src]

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

An empty regex (which never matches any text).

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

Fields

The characters.

Whether to match case insensitively.

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

Fields

The bytes.

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.

Match any character.

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

Match any byte.

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

A character class.

A character class with byte ranges only.

Match the start of a line or beginning of input.

Match the end of a line or end of input.

Match the beginning of input.

Match the end of input.

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

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

Match an ASCII word boundary.

Match a position that is not an ASCII word boundary.

A group, possibly non-capturing.

Fields

The expression inside the group.

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

The capture name, only for capturing named groups.

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

Fields

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

The type of repeat operator used.

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

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.

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]

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.

Returns a set of literal prefixes extracted from this expression.

Returns a set of literal suffixes extracted from this expression.

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

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

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

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

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

Trait Implementations

impl Clone for Expr
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Debug for Expr
[src]

Formats the value using the given formatter.

impl PartialEq for Expr
[src]

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

This method tests for !=.

impl Eq 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.

Formats the value using the given formatter.