> For the complete documentation index, see [llms.txt](https://doc.wearepatchworks.com/product-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-shapes/standard-shapes/filter-shape/using-regex-for-string-type-filters.md).

# Using regex for string-type filters

## Introduction

When adding filters for a string-type field, there may be times when standard operators can't achieve what you need. For example, when defining multiple filter conditions, the default condition is AND - so ALL specified filters must be met for a match. But what if you need an OR condition?

For more complex filtering requirements, regex can be used.

{% hint style="info" %}
This information applies wherever filters are available, not just the filter shape.&#x20;
{% endhint %}

## Regex filter example

Let's take the following payload:

{% code lineNumbers="true" %}

```json
[
    {
        "fruit": "apples pears grapes"
    },
    {
        "fruit": "grapes peaches raspberries"
    },
    {
        "fruit": "peaches"
    },
    {
        "fruit": "melon"
    }
]
```

{% endcode %}

Suppose we want to retrieve any items where the value of the `fruit` field contains `peaches` OR `apples`.  We might be tempted to add two string-type filters in the filter shape:

<table data-card-size="large" data-view="cards"><thead><tr><th></th><th></th><th></th></tr></thead><tbody><tr><td><img src="/files/BCNWneR5Hon016OwD1Qj" alt=""></td><td></td><td></td></tr><tr><td><img src="/files/HNKbXHwU3eBIb4LTk9Vv" alt=""></td><td></td><td></td></tr></tbody></table>

However, this wouldn't return any matches because we'd be looking for any records where `peaches` AND `apples` are present. Instead, we can define one string-type filter with regex:

<table data-card-size="large" data-view="cards"><thead><tr><th></th><th></th><th></th></tr></thead><tbody><tr><td><img src="/files/74hQ8EwbRUruPyBo5KWA" alt="" data-size="original"></td><td></td><td></td></tr><tr><td>This will return the correct payload - i.e. any records where peaches AND apples are present:</td><td><img src="/files/VqFmaem3HkikZ01QFIst" alt=""></td><td></td></tr></tbody></table>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-shapes/standard-shapes/filter-shape/using-regex-for-string-type-filters.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.
