> For the complete documentation index, see [llms.txt](https://docs.veza.com/4yItIzMvkpAvMVFAamTf/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.veza.com/4yItIzMvkpAvMVFAamTf/features/search/regex.md).

# Regular Expressions

Graph search, Query Builder, and Workflows can use regular expressions to filter results with matching attributes.

{% hint style="info" %}
Use regular expressions to create filters with OR conditions, or when complex pattern matching is needed. Otherwise, a built-in operator might already cover your use case (*Contains*, *Starts With*, *Not Ends With*, and others).
{% endhint %}

### Overview

A regular expression is a sequence of characters that define a *pattern* of symbols to match in search results. At the most basic level, a regular expression works similarly to text search: the regular expression `production` will match the exact text string "production". More complex expressions can match a pair of values, such as `dev|production`, or match a sequence of possible characters: `[A-Za-z0-9]`.

### Examples

Using a regular expression when filtering results by attribute can enable flexible searches, workflows, and alert rules. Notably, regular expressions allow for matching more than one combination (*OR*), unlike *contains* and *does not contain* filters (where all conditions must be true).

* Filter by multiple regions: (`us-(east|west)-\d+`)
* Match text containing a string: (`.*production.*`)
* Filter data resources in all US regions: (`us-[A-Za-z]*`)
* Check if a value is an expected format, such as a standard email: `\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b`

#### Notes and Resources

Regular expressions can contain character literals, operators, and constructs. For more information, see:

* [Perl Regular Expressions Tutorial](https://perldoc.perl.org/perlretut)

A variety of sandboxes can be found online for learning, building, and testing regular expressions.

### Supported Expressions

Veza implements a subset of [Perl Compatible Regular Expressions](https://perldoc.perl.org/perlre).

* Special characters such as `*+?()|` must be escaped with `\`

Possible expressions include:

#### Composites

* `xy` - `x` followed by `y`
* `x|y` - `x` or `y` (prefer `x`)

#### Repetitions

* `x*` - zero or more `x`, prefer more
* `x+` - one or more `x`, prefer more
* `x?` - zero or one `x`, prefer one
* `x{n,}` - `n` or more `x`, prefer more
* `x{n}` - exactly `n` `x`
* `x*?` - zero or more `x`, prefer fewer
* `x+?` - one or more `x`, prefer fewer
* `x??` - zero or one `x`, prefer zero
* `x{n,}?` - `n` or more `x`, prefer fewer
* `x{n}?` - exactly `n` `x`

#### Grouping

* `(re)` - numbered capturing group (submatch)
* `(?P<name>re)` - named & numbered capturing group (submatch)
* `(?:re)` - non-capturing group
* `(?flags)` - set flags within current group; non-capturing
* `(?flags:re)` - set flags during re; non-capturing

#### Flags

* `i` case-insensitive (default false)
* `m` multi-line mode (default false)
* `s` let `.` match (default false)
* `U` ungreedy: swap meaning of `x*` and `x*?`, `x+` and `x+?` (default false)

Flag syntax is `xyz` (set) or `-xyz` (clear) or `xy-z` (set `xy`, clear `z`).

#### Empty Strings

* `^` - at beginning of text or line
* `$` - at end of text

#### Character Class Elements

* `.` - any character, possibly including newline.
* `x` - single character
* `A-Z` - character range (inclusive)
* `\d` - Perl character class
* `[:class:]` - ASCII character class `class`
* `\p{class}` - Unicode character class `class`
* `\pF` - Unicode character class `F` (one-letter name
* `[\d]` - digits (≡ `\d`)
* `[^\d]` - not digits (≡ `\D`)
* `[\D]` - not digits (≡ `\D`)
* `[^\D]` - not not digits (≡ `\d`)

#### Perl character classes (ASCII-only)

* `\d` - digits (≡ `[0-9`)
* `\D` - not digits (≡ `[^0-9`)
* `\s` - whitespace (≡ `[\t\n\f`)
* `\S` - not whitespace (≡ `[^\t\n\f`)
* `\w` - word characters (≡ `[0-9A-Za-z_`)
* `\W` - not word characters (≡ `[^0-9A-Za-z_`)

#### ASCII Character Class

* `[[:alnum:]]` - alphanumeric (≡ `[0-9A-Za-z]`)
* `[[:alpha:]]` - alphabetic (≡ `[A-Za-z]`)
* `[[:ascii:]]` - ASCII (≡ `[\x00-\x7F]`)
* `[[:blank:]]` - blank (≡ `[\t ]`)
* `[[:cntrl:]]` - control (≡ `[\x00-\x1F\x7F]`)
* `[[:digit:]]` - digits (≡ `[0-9]`)
* `[[:graph:]]` - graphical (≡ `[!-~]`)
* `[[:lower:]]` - lower case (≡ `[a-z]`)
* `[[:print:]]` - printable (≡ `[ -~]` ≡ `[ [:graph:]]`)
* `[[:punct:]]` - punctuation (≡ `[!-/:-@[-{-~]`)
* `[[:space:]]` - whitespace (≡ `[\t\n\v\f\r ]`)
* `[[:upper:]]` - upper case (≡ `[A-Z]`)
* `[[:word:]]` - word characters (≡ `[0-9A-Za-z_]`)
* `[[:xdigit:]]` - hex digit (≡ `[0-9A-Fa-f]`)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.veza.com/4yItIzMvkpAvMVFAamTf/features/search/regex.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
