Skip to main content
The Text Matcher evaluator examines the textual content of your LLM’s response to check for specific patterns, keywords, or regex matches. Use it to enforce content requirements, detect unwanted text, or validate response format — all without writing code.

Set up the Text Matcher evaluator

1

Select the evaluator

Add the Text Matcher evaluator from the evaluator menu.Selecting the Text Matcher evaluator
2

Configure matching rules

Give the evaluator a name, link a dataset, and define the text matching rules.Configuring text matching rulesChoose from the following match types:
Match typeBehavior
equalsThe response must match your text exactly.
starts-withThe response must begin with your specified text.
ends-withThe response must conclude with your specified text.
contains-anyThe response must include at least one item from your array of strings.
contains-allThe response must include every item from your array of strings.
not-contains-anyThe response must not include any item from your array of strings.
regexThe response must match your regular expression pattern.
3

Run the evaluation

Click Evaluate to execute the evaluation and see the results.Text Matcher evaluator results

Examples

Find SEO-oriented keywords

Use contains-all or contains-any to ensure responses include target keywords: Finding SEO-oriented keywords

Ensure the response begins with a specific phrase

Use starts-with to enforce a consistent response opening: Ensuring a response starts with a specific phrase

Ensure the response does not contain personal information

Use not-contains-any to detect and flag responses that leak sensitive data: Blocking personal information in responses

Validate format with regex

Use regex to enforce structural patterns (e.g., lowercase letters and numbers only): Using regex in the Text Matcher

When to use

  • Keyword enforcement — Ensure required terms or phrases appear in responses (SEO, compliance, branding).
  • Content safety — Block responses containing banned words, personal information, or inappropriate content.
  • Format validation — Check that responses follow a specific format (e.g., starts with a greeting, ends with a call to action).
  • Simple pattern checks — Validate output structure with regex (email patterns, phone numbers, structured IDs).
For complex multi-step validation, consider the JavaScript evaluator. For qualitative assessment, use LLM-as-a-Judge.

Next steps

JavaScript Evaluator

Write custom code for more complex validation.

LLM-as-a-Judge

Use an LLM for qualitative assessment.