Guides
Custom Patterns
Create custom regex patterns to detect proprietary PII formats specific to your organization. Available on Professional and Enterprise tiers.
Professional+ Feature: Custom patterns are available on Professional (up to 50 patterns) and Enterprise (unlimited) tiers.
Pattern Structure
Each custom pattern consists of:
{
"name": "CUSTOMER_ID", // Unique identifier (alphanumeric + underscores)
"pattern": "CUS-[A-Z]{2}[0-9]{6}", // JavaScript regex pattern
"description": "Internal customer identifier format" // Optional description
}name
A unique identifier for the entity type. Must be alphanumeric with underscores, max 32 characters. This name will appear in redacted output as [CUSTOMER_ID].
pattern
A valid JavaScript regex pattern. Max 500 characters. Don't include the leading and trailing slashes or flags—we handle those automatically.
description
Optional human-readable description of what this pattern matches.
Example Patterns
Customer ID
Match internal customer identifiers like "CUS-AB123456"
{
"name": "CUSTOMER_ID",
"pattern": "CUS-[A-Z]{2}[0-9]{6}",
"description": "Format: CUS-XX000000"
}Employee Badge Number
Match employee badge numbers like "EMP-2024-00123"
{
"name": "EMPLOYEE_BADGE",
"pattern": "EMP-[0-9]{4}-[0-9]{5}",
"description": "Format: EMP-YYYY-NNNNN"
}Internal Project Code
Match project codes like "PROJ-ALPHA-2024"
{
"name": "PROJECT_CODE",
"pattern": "PROJ-[A-Z]{3,10}-[0-9]{4}",
"description": "Internal project identifier"
}Medical Record Number
Match custom MRN format like "MRN:12345678"
{
"name": "CUSTOM_MRN",
"pattern": "MRN:[0-9]{8}",
"description": "Custom medical record number format"
}Adding Patterns to Policies
Add custom patterns when creating or updating a policy:
// Create policy with custom patterns
POST /api/policies
Content-Type: application/json
{
"name": "Healthcare Policy",
"entity_types": ["PERSON", "SSN", "EMAIL"],
"custom_patterns": [
{
"name": "CUSTOM_MRN",
"pattern": "MRN:[0-9]{8}",
"description": "Medical record number"
},
{
"name": "PATIENT_ID",
"pattern": "PT-[A-Z]{3}-[0-9]{6}",
"description": "Patient identifier"
}
],
"redaction_format": "hash"
}Pattern Test BenchNew
Test your patterns before deploying using the pattern test endpoint. Includes ReDoS protection with a 100ms execution timeout.
/api/patterns/testTest a regex pattern against sample text. Includes ReDoS protection with a 100ms timeout.
Request Body
{
"pattern": "\\d{4}-[A-Z]{2}-\\d{5}-[A-Z]{3}",
"text": "Case number 2024-CV-12345-ABC was filed on January 15."
}Response
{
"valid": true,
"matches": [
{
"value": "2024-CV-12345-ABC",
"start": 12,
"end": 29
}
],
"execution_time_ms": 0.3,
"redos_safe": true
}Use the visual regex builder in the dashboard to design and test patterns interactively.
Pattern VersioningNewEnterprise
Custom patterns are automatically versioned on every regex update. You can view version history and rollback to any previous version.
List Pattern Versions
GET /api/patterns/:id/versions
Returns all versions of a pattern with metadata.
Rollback to Version
POST /api/patterns/:id/rollback
Request body: {"version": 3}
Note: Auto-versioning happens on regex updates. Metadata-only changes (name, description) don't create new versions.
Custom Pattern APINew
Full CRUD endpoints for managing custom patterns programmatically.
List Patterns
GET /api/patterns
Returns all custom patterns for your account.
Create Pattern
POST /api/patterns
Body: name, pattern, description
Update Pattern
PATCH /api/patterns/:id
Triggers new version on regex changes (Enterprise).
Delete Pattern
DELETE /api/patterns/:id
Permanently removes a pattern from your account.
Regex Best Practices
Be Specific
Use precise patterns to avoid false positives. CUS-[A-Z]{2}[0-9]{6}is better than CUS-.*.
Use Word Boundaries
Add \b at the start and end to match whole words only:\bCUS-[A-Z]{2}[0-9]{6}\b
Escape Special Characters
Escape dots, brackets, and other regex metacharacters:192\.168\.1\.[0-9]{1,3}
Test First
Use the built-in pattern tester in the dashboard to verify your patterns match expected values before saving.
Keep It Simple
Complex patterns slow down detection. If you need complex logic, consider multiple simpler patterns.
Common Regex Constructs
| Pattern | Meaning | Example Match |
|---|---|---|
| [0-9]{6} | Exactly 6 digits | 123456 |
| [A-Z]{2,4} | 2-4 uppercase letters | AB, ABC, ABCD |
| [A-Za-z0-9]+ | One or more alphanumeric | Abc123 |
| \d{3}-\d{4} | Digits with dash | 123-4567 |
| \b\w+\b | Whole word | word |
| (?:USD|EUR)\d+ | Non-capturing group | USD100, EUR50 |
Limits
- •Professional: Up to 50 custom patterns per policy
- •Enterprise: Unlimited custom patterns
- •Pattern length: Maximum 500 characters
- •Name length: Maximum 32 characters (alphanumeric + underscore)
- •Pattern versioning: Enterprise only — automatic version history and rollback