> This page is for version v0.24.0.
> For other versions, use one of these documentation indexes:
> - Latest (default): https://docs.nvidia.com/nemo/guardrails/latest/llms.txt
> - v0.24.1: https://docs.nvidia.com/nemo/guardrails/v0.24.1/llms.txt
> - v0.24.0: https://docs.nvidia.com/nemo/guardrails/v0.24.0/llms.txt
> - v0.23.0: https://docs.nvidia.com/nemo/guardrails/v0.23.0/llms.txt
> - v0.22.0: https://docs.nvidia.com/nemo/guardrails/v0.22.0/llms.txt

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/nemo/guardrails/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/nemo/guardrails/_mcp/server.

# nemoguardrails.library.regex.actions

## Module Contents

### Classes

| Name                                                                                 | Description |
| ------------------------------------------------------------------------------------ | ----------- |
| [`RegexDetectionResult`](#nemoguardrails-library-regex-actions-RegexDetectionResult) | -           |

### Functions

| Name                                                                                 | Description                                                           |
| ------------------------------------------------------------------------------------ | --------------------------------------------------------------------- |
| [`_regex_outcome`](#nemoguardrails-library-regex-actions-_regex_outcome)             | -                                                                     |
| [`detect_regex_pattern`](#nemoguardrails-library-regex-actions-detect_regex_pattern) | Checks whether the provided text matches any forbidden regex pattern. |

### Data

[`log`](#nemoguardrails-library-regex-actions-log)

### API

```python
class nemoguardrails.library.regex.actions.RegexDetectionResult
```

**Bases:** `typing.TypedDict`

**`detections`** `List[str]`

---

**`is_match`** `bool`

---

**`text`** `str`

---

```python
nemoguardrails.library.regex.actions._regex_outcome(
    source: str,
    result: nemoguardrails.library.regex.actions.RegexDetectionResult
) -> nemoguardrails.actions.rail_outcome.RailOutcome
```

```python
nemoguardrails.library.regex.actions.detect_regex_pattern(
    source: str,
    text: str,
    config: nemoguardrails.RailsConfig,
    kwargs = {}
) -> nemoguardrails.actions.rail_outcome.RailOutcome
```

async

Checks whether the provided text matches any forbidden regex pattern.

**Parameters:**

**`source`** `str`

The source for the text, i.e. "input", "output", "retrieval".

---

**`text`** `str`

The text to check.

---

**`config`** `RailsConfig`

The rails configuration object.

---

**Returns:** `RailOutcome`

RailOutcome with RegexDetectionResult fields in metadata:

* is\_match (bool): Whether any pattern matched.
* text (str): The original text that was checked.
* detections (List\[str]): List of pattern strings that matched.

```python
nemoguardrails.library.regex.actions.log = logging.getLogger(__name__)
```