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:
This matches any text containing "Renewal", "Upsell", or "Cross-Sell"
2. Checking for Empty Values
To check if a field is empty:
To check if a field is not empty:
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_"
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 endThe
|
combines these patterns with OR logic
4. Special Character Matching
If you need to match special characters like "|" in your text:
This tells regex to treat the "|" as regular text, not as an OR operator.
Testing Your Regex
Paste your pattern (without the
/
delimiters)Test it against your sample text
The website will explain each part of your pattern
Best Practices
Start Simple: Begin with basic patterns and build up complexity
Test Thoroughly: Always test your regex with various examples
Document: Keep notes about what each regex pattern does
Break It Down: Split complex patterns into smaller, understandable pieces
Consider Case: Remember that HockeyStack regex is case sensitive
Need Help?
If you're unsure about a pattern:
Break down what you're trying to match
Test it on regex101.com
Start with simple patterns
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.
Last updated