> 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 full documentation content, see https://docs.nvidia.com/nemo/guardrails/llms-full.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_blocked_mapping`](#nemoguardrails-library-regex-actions-_regex_blocked_mapping) | Return True (blocked) when a regex match was found.                   |
| [`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`

```python
nemoguardrails.library.regex.actions._regex_blocked_mapping(
    result: nemoguardrails.library.regex.actions.RegexDetectionResult
) -> bool
```

Return True (blocked) when a regex match was found.

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

async

Checks whether the provided text matches any forbidden regex pattern.

**Parameters:**

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

The text to check.

The rails configuration object.

**Returns:** `RegexDetectionResult`

A TypedDict containing:

* 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__)
```