The Regex Detect plugin scans user and assistant messages for specified regex patterns and can either reject requests containing matches or redact the matched content.Documentation Index
Fetch the complete documentation index at: https://docs.datawizz.ai/llms.txt
Use this file to discover all available pages before exploring further.
Features
- Flexible Pattern Matching: Configure multiple regex patterns with optional flags
- Selective Scanning: Choose to scan only the latest message or all messages in the conversation
- Reject or Redact: Either block requests containing sensitive data or automatically redact it
- Custom Messages: Define custom rejection messages for different patterns
- Configurable Redaction: Use static text or character repetition for redaction
Use Cases
- Filter sensitive information (emails, phone numbers, credit cards)
- Enforce content policies by blocking specific patterns
- Automatically redact PII (Personally Identifiable Information)
- Prevent prompt injection attacks by detecting suspicious patterns
Configuration Options
patterns (required)
Array of pattern objects to scan for. Each pattern object contains:
regex(string, required): The regular expression pattern to matchflags(string, optional): Regex flags (e.g., ‘gi’ for global case-insensitive). Default: ‘g’rejectMessage(string, optional): Custom message to return when this pattern is matched
scanAllMessages (boolean)
true: Scans all messages in the arrayfalse: Only scans the latest message- Default:
false
redactMatches (boolean)
true: Redacts matched patterns instead of rejecting the requestfalse: Rejects the request if a match is found- Default:
false
redactionText (string)
Text to replace redacted patterns with. Default: [REDACTED]
redactCharacters (string)
If set, replaces each match with this character repeated to match the length of the original text. Overrides redactionText if both are set.
Example Configurations
Block Email Addresses
Redact Phone Numbers
Redact Credit Cards with Character Masking
Multiple Patterns
Response Behavior
When Rejecting (redactMatches: false)
- Returns
reject: truewith a rejection reason - Uses custom
rejectMessageif provided, otherwise a default message - No messages are modified
When Redacting (redactMatches: true)
- Returns modified messages array with redacted content
- Original request continues through the pipeline
- Debug logs indicate how many matches were redacted
Common Regex Patterns
- Email:
\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b - US Phone:
\b\d{3}[-.]?\d{3}[-.]?\d{4}\b - Credit Card:
\b\d{4}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b - SSN:
\b\d{3}-\d{2}-\d{4}\b - IP Address:
\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b - URL:
https?://[^\s]+
Notes
- Patterns are tested in order; the first match determines the rejection message
- Invalid regex patterns are logged in debug output but don’t fail the request
- The ‘g’ (global) flag is recommended for finding all matches
- When using
redactCharacters, the replacement length always matches the original