Skip to content

Grader: output-matches

PropertyValue
Determinismstatic
Costfree
Portabilityt1-universal
Referencereference-free
Temporal scopetrajectory-level
Score kindcode
graders:
- type: output-matches
config:
pattern: "function\\s+\\w+\\("
FieldTypeRequiredDescription
patternstringYesRegular expression pattern to match against output
negatebooleanNoWhen 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.

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+\(/