Catch the Regex Mistake Before It Breaks a Trigger or a Report
Type a pattern and your test values. This free GTM regex tester shows what matches in Google Tag Manager (partial match) and in GA4 (full match), highlights the matched part and the capture groups, and warns about anything RE2 does not support, such as lookahead. It also explains the pattern in plain English and includes a library of 24 ready regex patterns for tracking work.
Type a pattern, choose where you will use it and add test values. Results update as you type.
Everything is tested in your browser. Your pattern and test strings are not sent anywhere.
Paste the values you want to match. Special characters such as dots and question marks are escaped for you. The pattern is written for the mode chosen above.
Click a pattern to load it with sample test strings. Domains and IDs are fictional examples: replace shop.example with your own domain.
The differences between GTM and GA4 that make a correct-looking pattern fail.
GTM matches anywhere in the value. GA4 “matches regex” needs the whole value. Test either one.
Each test value is marked Match or No match, with the matched part highlighted.
See what each pair of brackets captures, for RegEx Table variables and URL parts.
Lookahead, lookbehind, backreferences, possessive quantifiers and atomic groups are flagged.
Unescaped dots and question marks, stray | signs, spaces and missing anchors.
The pattern is broken into parts with a short meaning for each one.
Paste a list of values and get an escaped pattern for equals, contains, starts with or ends with.
Ready patterns for thank-you pages, downloads, IP ranges, click IDs, subdomains and more.
Three steps. Your pattern stays in your browser.
Type your own, build one from a list of values, or load one from the library.
Pick the condition you will use, so the test follows the same matching rule.
See which test values match, what each group captures, and any warning with its fix.
A regular expression, or regex, is a pattern that describes text. In tracking work you use it to say “any thank-you page”, “these five domains” or “links that end in .pdf”. The same pattern can behave differently in Google Tag Manager and in Google Analytics 4. This GTM regex tester shows both.
/pro/ matches any value that contains /pro/. Add ^ and $ when you need an exact start or end..*text.*.RE2 is the regex engine behind GA4, BigQuery and Looker Studio. It is built to be fast and safe, so it leaves out a few features that JavaScript has:
(?!internal).\1.A pattern with lookahead can work in a GTM trigger and then fail when you paste it into a GA4 filter. To exclude something in GA4, use a plain pattern with a “does not match regex” condition.
The test runs in your browser’s JavaScript engine. It does not run RE2 itself: RE2 differences are flagged by a set of rules, so an unusual pattern could behave differently in GA4 without a warning here. The tool also cannot see the real values on your site, such as the exact Page Path or Click URL that GTM reads. Always confirm a pattern in GTM Preview mode, or in a GA4 report, before you rely on it.
The characters you need most often in GTM triggers and GA4 filters.
| Symbol | Meaning | Example |
|---|---|---|
. | Any single character | a.c matches abc and a-c |
\. | A real dot | shop\.example |
^ | Start of the value | ^/blog starts with /blog |
$ | End of the value | \.pdf$ ends with .pdf |
| | Or | cart|checkout |
( ) | Group, and capture what is inside | ^/(en|de)/ |
? | The item before it is optional | /pricing/? |
* and + | Zero or more, one or more | .* is “anything” |
[ ] | One character from a set | [0-9] is a digit |
{2,4} | Repeat 2 to 4 times | [0-9]{5,10} |
\d | A digit | ^ORD-\d{6}$ |
\? | A real question mark | /search\?q= |
Test trigger conditions and RegEx Table patterns before you publish.
Check that a filter pattern survives the full-match rule and RE2.
Load a ready pattern and swap in your own pages or domains.
See which JavaScript regex features will not carry over to GA4 or BigQuery.
33 free tools for tracking, analytics, advertising and SEO. No login needed.
Scan a landing page and keywords for Quality Score, ad copy, CTR and tracking issues.
Open the Google Ads audit →Ready-to-run SQL for the GA4 BigQuery export: revenue by source, funnels, items and more.
Open the SQL generator →Write responsive search ad headlines and descriptions with live character counts.
Open the ad copy generator →Get a tracking plan for your business type: events, parameters and platform mapping in Excel.
Open the plan generator →Hear from our clients. Loved by 600+ businesses worldwide.
“I had an excellent experience working with MD on my Google Ads account. Everything was set up perfectly and worked smoothly without any issues or troubleshooting needed. His expertise and attention to detail made the whole process effortless.”
“I worked with Niamul on multiple Google Analytics projects and was impressed by his expertise and precision. He has a strong grasp of tracking, reporting, and optimization, always ensuring accurate insights. He is proactive, reliable, and easy to collaborate with.”
“MD Niamul is extremely skilled. He fixed my Shopify, Google Analytics, and Google Ads conversion tracking perfectly. Everything works exactly as it should now, and he even added an extra data layer, which was very helpful. Outstanding service, fast delivery, and highly recommended.”
“Reliable, knowledgeable, and truly trustworthy. I’ve been working with Niamul for over a year, and he consistently delivers exceptional results across all analytics tasks. His expertise, communication, and commitment make him my go-to specialist for tracking, measurement, and data accuracy.”
“MD N delivered flawless Meta Pixel, CAPI, and server-side tracking. He understood our goals quickly, explained everything clearly, and ensured full transparency. Communication was smooth, updates were consistent, and the results improved our data accuracy and ad performance.”
Five-star reviews from businesses and agencies in the USA, Canada, UK and Australia.
Read All ReviewsYes. It runs in your browser with no login. Your pattern and test strings are not sent anywhere.
Part of it. A GTM regex condition is true when the pattern is found anywhere in the value. Add ^ at the start and $ at the end when the whole value has to match.
There are two usual reasons. GA4 “matches regex” needs the whole value to match, so you may need .* around your text. And GA4 uses RE2, which does not support lookahead, lookbehind or backreferences.
RE2 is Google’s regular expression engine. GA4, BigQuery and Looker Studio use it. It is fast and predictable, but it leaves out lookaround and backreferences.
In GTM choose the “matches RegEx (ignore case)” condition. In GA4 add (?i) at the start of the pattern. GA4 conditions are case-sensitive by default.
A dot on its own means “any character”, so shop.example would also match shopXexample. Writing \. matches a real dot only.
A pair of brackets that remembers the text it matched. In a GTM RegEx Table variable you can reuse that text in the output, for example to pull a product ID out of a URL.
No. It runs your pattern in your browser’s JavaScript engine and uses rules to flag the features RE2 does not support. Confirm the result in GA4 before you rely on it.
Yes, GTM runs JavaScript regex, which supports lookahead. Lookbehind fails in older Safari versions, and neither will work if you later reuse the pattern in GA4 or BigQuery.
I am MD Niamul, a conversion tracking and web analytics specialist and an official Stape partner. I build and audit Google Tag Manager containers, triggers and GA4 setups, and test every condition so your tags fire when they should and your reports are accurate.