Skip to main content
Compiles a regex and reports a binary match / mismatch against the model’s output — handy for asserting format invariants like phone numbers, currency strings, UUIDs, or identifier prefixes without paying for a model call. For a zero-code option, see the pre-built Regex Match metric. Use the version below when you want to extend the logic — capture groups, multiple alternative patterns, richer explanations.

Code

Both re.search and String.match find a match anywhere in the string. If you need the entire output to match, switch to re.fullmatch in Python, or anchor the pattern with ^...$ in TypeScript.

Input mapping

Output configuration

Categorical labels: Optimization direction: maximize.

Runtime requirements

Untrusted regex patterns can be vulnerable to catastrophic backtracking (ReDoS). If pattern is sourced from per-example dataset values rather than a fixed literal, prefer patterns from a trusted column you control.