# 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

`Empty` | An empty regex (which never matches any text). |
`Literal` | A sequence of one or more literal characters to be matched. ### Fields
`chars` | The characters.
`casei` | Whether to match case insensitively.
`LiteralBytes` | A sequence of one or more literal bytes to be matched. ### Fields
`bytes` | The bytes.
`casei` | 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` | A character class. |
`ClassBytes` | 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
`e` | The expression inside the group.
`i` | The capture index (starting at `1`) only for capturing groups.
`name` | The capture name, only for capturing named groups.
`Repeat` | A repeat operator (`?`, `*`, `+` or `{m,n}`). ### Fields
`e` | The expression to be repeated. Limited to literals, `.`, classes or grouped expressions.
`r` | The type of repeat operator used.
`greedy` | Whether the repeat is greedy (match the most) or not (match the least).
`Concat` | 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` | 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`

#### `fn parse(s: &str) -> Result<Expr>`

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.

#### `fn prefixes(&self) -> Literals`

Returns a set of literal prefixes extracted from this expression.

#### `fn suffixes(&self) -> Literals`

Returns a set of literal suffixes extracted from this expression.

#### `fn is_anchored_start(&self) -> bool`

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

#### `fn is_anchored_end(&self) -> bool`

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

#### `fn has_bytes(&self) -> bool`

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

## Trait Implementations

### `impl Display for Expr`

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

#### `fn fmt(&self, f: &mut Formatter) -> Result`

### Derived Implementations

### `impl Eq for Expr`

### `impl PartialEq for Expr`

#### `fn eq(&self, __arg_0: &Expr) -> bool`

#### `fn ne(&self, __arg_0: &Expr) -> bool`

### `impl Debug for Expr`

#### `fn fmt(&self, __arg_0: &mut Formatter) -> Result`

### `impl Clone for Expr`

#### `fn clone(&self) -> Expr`

#### `fn clone_from(&mut self, source: &Self)`1.0.0

# Help

## Keyboard Shortcuts

?
  Show this help dialog
S
  Focus the search field
⇤
  Move up in search results
⇥
  Move down in search results
⏎
  Go to active search result

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)