Skip to content

Grader: output-matches

Property Value
Determinism static
Cost free
Reference reference-free
Temporal scope trajectory-level
Score kind code
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

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.

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-insensitive

Passes when the pattern matches (or does NOT match if negated). Fails otherwise.

✔ Output matches pattern /function\s+\w+\(/
✘ Output does not match pattern /function\s+\w+\(/