> For the complete documentation index, see [llms.txt](https://docs.raga.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.raga.ai/ragaai-catalyst/ragaai-metric-library/guardrails/regex-check.md).

# Regex Check

Validate outputs using regex guardrails. Catch unsafe, malformed, or non-compliant responses automatically.

**Objective**\
This metric validates responses against predefined regex patterns, ensuring compliance with specific formats (e.g., email, date, or phone formats).

**Interpretation**\
A higher score indicates that the response does not comply with the required regex format or fails validation. A lower (or zero) score indicates compliance.

**Code Execution**

```python
metrics = [
    {
        "name": "Regex Check",
        "config": {
            "model": "gpt-4o-mini",
            "provider": "openai"
        },
        "column_name": "your-column-identifier",
        "schema_mapping": schema_mapping
    }
]
```

**Example**

* **Prompt**: “Enter your email address.”
* **Context**: “Valid email format: <username@domain.com>”
* **Response**: “myemail\[at]example.com”
* **Metric Output**: `{"score": 1, "reason": "Response does not match the required email regex format."}`
