# Apply patterns, custom indexes, filtering, and exclusions

This page provides examples of regular expression patterns and how they could be structured to create display lists.&#x20;

Creating these regular expression patterns will be determined by the information available via your APIs and how they are structured.&#x20;

The examples provided here are intended to provide guidance in creating meaningful ways of presenting information to your users via the use of [*Display List* nodes](/flow/action-nodes/action-nodes-display-list.md) and [*Dynamic List* node](/flow/user-facing-nodes/branch-logic-split/menu-nodes-dynamic-list.md).

## Examples

```
{
    "products": [
        {
            "id": "1001",
            "desc": "Potatoes",
            "unitPrice": 100,
            "category": "veg"
        },
        {
            "id": "1002",
            "desc": "Melon",
            "unitPrice": 200,
            "category": "fruit"
        },
        {
            "id": "1003",
            "desc": "Grapes",
            "unitPrice": 300,
            "category": "fruit"
        },
        {
            "id": "1004",
            "desc": "Milk",
            "unitPrice": 400,
            "category": "dairy"
        }
    ]
}
```

Example session variables that will be used in the below explanations (produced for example as a result of an earlier [*API Integration*](/flow/configuration/api-integration.md) node):

* "\[\[EXAMPLE:products.1.id]]":  "1001"
* "\[\[EXAMPLE:products.1.desc]]":  "Potatoes"
* "\[\[EXAMPLE:products.1.unitPrice]]":  100
* "\[\[EXAMPLE:products.1.category]]":  "veg"
* "\[\[EXAMPLE:products.2.id]]":  "1002"
* "\[\[EXAMPLE:products.2.desc]]":  "Melon"
* "\[\[EXAMPLE:products.2.unitPrice]]":  200
* "\[\[EXAMPLE:products.2.category]]":  "fruit"
* "\[\[EXAMPLE:products.3.id]]":  "1003"
* "\[\[EXAMPLE:products.3.desc]]":  "Grapes"
* "\[\[EXAMPLE:products.3.unitPrice]]":  300
* "\[\[EXAMPLE:products.3.category]]":  "fruit"
* "\[\[EXAMPLE:products.4.id]]":  "1004"
* "\[\[EXAMPLE:products.4.desc]]":  "Milk"
* "\[\[EXAMPLE:products.4.unitPrice]]":  400
* "\[\[EXAMPLE:products.4.category]]":  "dairy"

## "Pattern" field

The *Pattern* field is used to match possible session variables that would be used to display to the user as a list. The pattern may contain the # character. If so, it is replaced with '1' and checked if it exists in the session store. If it exists, it is added to the list and it tries '2', etc. If it is not found then it is done and the list is returned.

For the above session variables, a "pattern" of "\[EXAMPLE:products.#.desc] (\[EXAMPLE:products.#.unitPrice] cents)" will (with a numbered list) return a list of

1. Potatoes (100)
2. Melon (200)
3. Grapes (300)
4. Milk (400)

For the above session variables, a "pattern" of "\[EXAMPLE:products.#.desc]" will (with a numbered list and ". " seperator/indexPattern) return a list of

1. Potatoes
2. Melon
3. Grapes
4. Milk

## "Custom Index" field

This is the separator field above and can also contain the "#" character to be replaced with the incrementing list counter. This field is not resolved (unlike with "pattern")

For the above session variables, a "pattern" of "\[EXAMPLE:products.#.desc]" will (with a numbered list and "--~~#~~--" indexPattern) return a list of

\--~~1~~-- Potatoes

\--~~2~~-- Melon

\--~~3~~-- Grapes

\--~~4~~-- Milk

For the above session variables, a "pattern" of "\[EXAMPLE:products.#.desc]" will (with a numbered list and "--->>" indexPattern) return a list of

\--->> Potatoes

\--->> Melon

\--->> Grapes

\--->> Milk

## "Filter By" field

Optional map of key value pairs where:&#x20;

* **key:** contains the expected text to include if matched by the pattern (the value).
* **value:** the pattern to evaluate (same as pattern fields above) to test against the key.

For the above session variables, a "pattern" of "\[EXAMPLE:products.#.desc]", and with a Filter By map of&#x20;

* key: "fruit"
* value: "\[EXAMPLE:products.#.category]"

will (with a numbered list and ". " seperator/indexPattern) return a list of

1. Melon
2. Grapes

## "Exclude" field

Optional map of key-value pairs where (same as "Filter By")

* **key**: contains the expected text to exclude if matched by the pattern (the value).
* **value**: the pattern to evaluate (same as pattern fields above) to test against the key.

For the above session variables, a "pattern" of "\[EXAMPLE:products.#.desc]", and with an "Exclude" map of&#x20;

* key: "fruit"
* value: "\[EXAMPLE:products.#.category]"

will (with a numbered list and ". " seperator/indexPattern) return a list of

1. Potatoes
2. Milk


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://guides.clickatell.com/flow/user-facing-nodes/branch-logic-split/menu-nodes-dynamic-list/apply-patterns-custom-indexes-filtering-and-exclusions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
