Create complex matching expressions using the AI Assistant

Even if you are not familiar with the syntax, BlazeMeter's AI Assistant helps you create complex expressions to match transactions seamlessly by letting you use natural language.

A common use case is matching dynamic URL patterns or request or response bodies of transactions. The AI Assistant can generate sophisticated expressions for Wiremock Handlebars, JavaScript (${#script} blocks), regular expression (Regex), and XPath, which are commonly used in headers, response matchers, and request matchers in transactions fields.

Like other AI-assisted features, the AI expression assistant requires explicit consent and opt-in. See Manage AI Consent and the Perforce Generative AI Policy for more details.

For an alternative method using a wizard, without AI consent, see also Generate paths for request matching and Generate paths for dynamic responses.

Motivation

When filling in matcher fields without the AI assistant, you would need to know Handlebar or regular expression syntax, write the expression in an external tool, validate and test the expression externally, copy and paste it into the URL field, redeploy the virtual service, retest the virtual service, and repeat the cycle if the expression didn't match as expected.

Using the built-in assistant speeds up this process considerably. Describe what you need in natural language, and the AI generates the appropriate expression along with a plain-English explanation of how it works. Either append the generated expression to an existing value, override the current field content, or simply copy it to the clipboard and reuse it elsewhere in your code.

Supported Languages

The AI Assistant helps you generate the following expression types:

  • Regular expressions (regex) — for pattern-based URL or value matching
    Examples: Exact Match, Starts With, Alphanumeric characters, negative or positive integer, Boolean, JWT Token, URL, numeric range, and many more.

  • JavaScript inside ${#script}…${/script} blocks — for computing dynamic response content. Useful when the logic is too complex for plain Handlebars (multi-step computation, JSON parsing, format conversion, conditional logic on multiple inputs). Available in the Response tab only.

  • XPath — for matching content within XML bodies

  • JSONPath — for matching content within JSON bodies

  • Handlebars — for dynamic Wiremock-style response templating

Supported input fields

The expression assistant is available in the following input fields of a transaction:

In the Request Matcher tab:

  • URL—Match incoming request URLs using regex or exact patterns

  • Headers—Match specific request header names and values (match regex)

  • Query Parameters—Match URL query string parameters and their values

  • Cookies—Match cookie names and values in the request

  • Body—Match request body content using regex, xpath, jsonpath, or handlebars

In the Response tab:

  • Headers—Define dynamic or pattern-based response header values

  • Body—Generate dynamic response body content using handlebars or other expressions

Generate a matching expression

You are creating a transaction that requires a flexible matching pattern in a field, but you don't know how to write the correct matching expression.

  1. Edit the transaction in the Asset Catalog.

  2. Navigate to the Request Matcher or Response tab.

  3. If applicable, select Matches Regex .

  4. Click the AI Assistant button inside the text box to open the AI assistant for the field you are defining.

  5. (Optional) To see examples of what the assistant can do for you, click a suggestion card.

  6. Type in your requirements for the expression in natural language.
    Example: "Match a URL path that starts with /pet/ followed by a five digit number"
    The assistant displays a suggested regular expression:
    /pet/\d\d\d\d\d$
  7. Validate the generated expression by entering sample data in the second field.
    Example: /pet/00158 validates, /pet/158 and /cat/34611 do not validate.

  8. Choose one of the following actions:

    • Append — To add the generated expression to any existing content in the field. Available only on URL, Response Body, and Body Matcher fields where building up an expression incrementally makes sense.

    • Override / Apply — To replace the field content with the generated expression

    • Replace Selection — To replace only the selected field content with the generated expression

    • Copy — To copy the expression to your clipboard for use elsewhere, and leave the field as is.

Each time the modal is opened on a different field, it starts fresh — the context is scoped to the field currently being edited.

To test the expression, validate transactions and matchers in the built-in sandbox now.

Examples

User: Give me a regex to match URLs with the pattern /book- followed by an alphanumeric ID
Assistant: ^/book-[a-zA-Z0-9]+$

User: Give me a regex to match the Content-Type header when it contains application/json but could also have parameters like charset=utf-8
Assistant: ^Content-Type:\s*application/json(?:;[^,\r\n]*)?$

User: Extract the order ID from the JSON request body and return it.
Assistant:
${#script}var body = JSON.parse(request.body); body.orderId${/script}${scriptresult}