Grader: output-matches
Taxonomy
Section titled “Taxonomy”| Property | Value |
|---|---|
| Determinism | static |
| Cost | free |
| Reference | reference-free |
| Temporal scope | trajectory-level |
| Score kind | code |
Config
Section titled “Config”graders: - type: output-matches config: pattern: "function\\s+\\w+\\("| Field | Type | Required | Description |
|---|---|---|---|
pattern |
string | Yes | Regular expression pattern to match against output |
negate |
boolean | No | When true, passes when the pattern does NOT match |
Negated variant
Section titled “Negated variant”Use output-not-matches as a shorthand for negate: true:
graders: - type: output-not-matches config: pattern: "(?i)error|exception"This is equivalent to type: output-matches with negate: true.
Behavior
Section titled “Behavior”Constructs a RegExp from the pattern and tests it against trajectory.output.
This is a regex search: the grader passes when the pattern matches anywhere in
the output, so output with extra text before or after the match still passes. To
require the entire output to match, anchor the pattern with ^ and $.
Inline flags: Use the (?flags) prefix syntax to set regex flags:
(?i)pattern— case-insensitive matching(?m)pattern— multiline (^/$match line start/end)(?s)pattern— dotAll (.matches newlines)(?ims)pattern— combine multiple flags
graders: - type: output-matches config: pattern: "(?i)function\\s+\\w+\\(" # case-insensitivePasses when the pattern matches (or does NOT match if negated). Fails otherwise.
Evidence examples
Section titled “Evidence examples”✔ Output matches pattern /function\s+\w+\(/✘ Output does not match pattern /function\s+\w+\(/