> For the complete documentation index, see [llms.txt](https://docs.hockeystack.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hockeystack.com/marketing-intelligence/dashboard-builder/using-the-new-dashboard-filters/using-regex.md).

# Using Regex

### Introduction

Regular Expressions (Regex) is a powerful tool that helps you create sophisticated filters without complex AND/OR blocks. While it might look intimidating at first, this guide will break it down into simple, practical concepts that marketers can use daily.

### Basic Syntax

#### The Building Blocks

💡 **Important:** Regex in HockeyStack is case sensitive

### Common Use Cases

#### 1. Contains One of Multiple Values

Instead of using multiple "contains" filters, use the OR operator:

```regex
/Renewal|Upsell|Cross-Sell/
```

This matches any text containing "Renewal", "Upsell", or "Cross-Sell"

#### 2. Checking for Empty Values

To check if a field is empty:

```regex
/^$/
```

To check if a field is not empty:

```regex
/./
```

#### 3. Brand Campaign Example

Let's say you want to match brand campaigns with these patterns:

* "*brand*" in the middle
* "brand\_" at the start
* "\_brand" at the end

But NOT match "nonbrand\_"

```regex
/_brand_|^brand_|_brand$/
```

Breaking it down:

* `_brand_` matches brand with underscores on both sides
* `^brand_` matches brand with underscore at the start
* `_brand$` matches brand with underscore at the end
* The `|` combines these patterns with OR logic

#### 4. Special Character Matching

If you need to match special characters like "|" in your text:

```regex
/\|/
```

This tells regex to treat the "|" as regular text, not as an OR operator.

### Testing Your Regex

1. Visit [regex101.com](https://regex101.com)
2. Paste your pattern (without the `/` delimiters)
3. Test it against your sample text
4. The website will explain each part of your pattern

### Best Practices

1. **Start Simple**: Begin with basic patterns and build up complexity
2. **Test Thoroughly**: Always test your regex with various examples
3. **Document**: Keep notes about what each regex pattern does
4. **Break It Down**: Split complex patterns into smaller, understandable pieces
5. **Consider Case**: Remember that HockeyStack regex is case sensitive

### Need Help?

If you're unsure about a pattern:

1. Break down what you're trying to match
2. Test it on regex101.com
3. Start with simple patterns
4. Add complexity one piece at a time

Remember: Regex is a powerful tool that becomes easier with practice. Start with simple patterns and gradually build up to more complex ones as you become comfortable with the basics.


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.hockeystack.com/marketing-intelligence/dashboard-builder/using-the-new-dashboard-filters/using-regex.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
