---
title: "Regex Match"
description: "Check whether a text matches a regular expression pattern."
---

Checks whether a text matches a regular expression pattern. By default, the pattern is searched anywhere in the text (partial match). Returns `true` if the pattern matches, `false` otherwise.

## Parameters

| Parameter | Type | Required | Default | Description |
|-----------|------|----------|---------|-------------|
| `pattern` | string | Yes | — | The regular expression pattern to match |
| `text` | string | Yes | — | The text to search |
| `full_match` | boolean | No | `false` | If `true`, the pattern must match the entire string; if `false`, a match anywhere in the text is sufficient |

## Output

| Property | Value | Description |
|----------|-------|-------------|
| `label` | `true` or `false` | Whether the pattern matched |
| `score` | `1.0` or `0.0` | Numeric score (`1.0` = match, `0.0` = no match) |
| Optimization | Maximize | Higher scores are better |

## Configuring Inputs

Each evaluator parameter can be set to either a **path** (a JSONPath expression that extracts a value from the evaluation parameters) or a **literal** (a fixed value typed directly). Use paths to pull from dataset inputs, task outputs, reference data, or metadata. Use literals for static configuration like regex patterns.

See [Input Mapping](/docs/phoenix/evaluation/server-evals/input-mapping) for full details on mapping modes, resolution order, and examples.

## Usage Examples

**Format compliance** — A model that must produce output in a specific structural format (a date, phone number, or identifier). **Pattern** is the regular expression defining the required format, set as a literal value. **Text** is the model's output field — use a direct path for a plain string response, or a nested path like `output.date` if the target value is embedded in a JSON object.

**Citation or reference checking** — A RAG pipeline that must include a URL, citation marker, or other structured element in every response. **Pattern** matches the expected element (e.g., a URL regex or citation format); **Text** is the model's full response. Partial match mode (the default) passes as long as the pattern appears anywhere in the output.

**Output type gating** — A code assistant whose output should contain a function definition rather than prose. **Pattern** is anchored to the expected code structure; **Text** is the response field. If your model returns structured JSON with a `code` key, map **Text** to `output.code` rather than the entire response.

## Notes

<Warning>
Complex regex patterns can be slow on long inputs. Avoid patterns with nested quantifiers or excessive backtracking (e.g., `(a+)+`, `.*.*`). Prefer anchored patterns and specific character classes over broad wildcards. Test your pattern against representative inputs before deploying to a large dataset.
</Warning>

## See Also

- [Pre-Built Metrics Overview](/docs/phoenix/evaluation/server-evals/pre-built-metrics)
- [Contains](/docs/phoenix/evaluation/server-evals/pre-built-metrics/contains) — check whether a text contains specific words
- [Exact Match](/docs/phoenix/evaluation/server-evals/pre-built-metrics/exact-match) — check whether two strings are identical
