Free tool Regex tester for JavaScript regular expressions
Type a pattern, paste some text and see every match highlighted as you type. The match table lists each capture group by number or name, the replace box previews the result, and the checks tell you when a pattern copied from PHP, Nginx or Python uses syntax JavaScript reads differently.
- Native JavaScript engine
- Groups and named groups
- Runs in your browser
Test a regular expression
Results update as you type. The pattern runs in a background worker and is stopped after 1.5 seconds, so a pattern that backtracks endlessly cannot freeze the page.
Saved to My tools
Open the free tools page next time and it is right at the top under My tools (stored in this browser only).
You can also press Ctrl+D to bookmark this page in your browser.You can also press ⌘+D to bookmark this page in your browser.You can also tap your browser’s Share button (at the bottom in Safari) and choose Add Bookmark or Add to Home Screen.You can also open the ⋮ menu at the top right and tap ☆ to bookmark it, or choose Add to Home screen.You can also tap ··· at the top right and choose Favorite, or open it in your browser and bookmark it there.
View My toolsWithout the slashes, or paste a whole literal such as /\d+/g and the flags are read from it.
g all matches, i ignore case, m ^ and $ per line, s dot matches newlines, u / v Unicode, y sticky, d match indices.
$1, $<name>, $& (whole match) and $$ (a dollar sign) work as in String.replace.
The whole text is searched at once, including line breaks. Up to 50,000 characters. Not saved and not included in share links.
Matches
3
Capture groups
3
In the pattern, counted left to right.
Characters tested
113
Checks
Syntax errors, flags, and constructs from other regex flavours that JavaScript reads differently.
- OKAlso valid RE2 syntax, so it can be reused in Go, GA4, BigQuery and Looker Studio (check case and full-match rules there).
Highlighted text
Matches alternate between two colours so neighbouring matches stay distinguishable. A thin bar marks an empty match.
Order 1042 shipped on 2026-11-27 and is due 2026-12-01. Invoice date: 2026-11-30 Not a date: 20261127, 2026/11/27
Match details
Position is the zero-based index, then line:column.
| # | Position | Match | Groups |
|---|---|---|---|
| 1 | 22 · 1:23 | 2026-11-27 | year: 2026 · month: 11 · day: 27 |
| 2 | 44 · 1:45 | 2026-12-01 | year: 2026 · month: 12 · day: 01 |
| 3 | 70 · 2:15 | 2026-11-30 | year: 2026 · month: 11 · day: 30 |
Order 1042 shipped on 27/11/2026 and is due 01/12/2026.
Invoice date: 30/11/2026
Not a date: 20261127, 2026/11/27The test text after String.replace with your pattern and flags. Without g, only the first match is replaced.
const re = /(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})/g;
for (const m of text.matchAll(re)) {
console.log(m.index, m[0], m.groups);
}
const out = text.replace(re, "$<day>/$<month>/$<year>");The same pattern as a literal, ready to paste.
Share these inputs: the values go after the # in the link, so they never reach a server.
https://tapcub.com/tools/regex-tester
Done here? Try these next
Use this tool often? Save it to My tools.Saved to My tools. Find it any time at the top of the free tools page. You can also press Ctrl+D to bookmark this page in your browser.You can also press ⌘+D to bookmark this page in your browser.You can also tap your browser’s Share button (at the bottom in Safari) and choose Add Bookmark or Add to Home Screen.You can also open the ⋮ menu at the top right and tap ☆ to bookmark it, or choose Add to Home screen.You can also tap ··· at the top right and choose Favorite, or open it in your browser and bookmark it there.
Problem or suggestion?Send feedbackChat with support
Version v1.0Updated Update history
What each part of the result tells you
The tester uses your browser’s own JavaScript engine, so what you see here is exactly what your code will do in Chrome, Safari, Firefox or Node.js.
- All flags: d g i m s u v y
- Named groups and replace preview
- Flags PCRE and Python syntax JS lacks

Matches
How many times the pattern matched. With the g flag, every non-overlapping match from left to right; without it, only the first one. An empty match (a pattern that can match zero characters) still counts.
Highlighted text
The whole test text with matches marked. Two colours alternate so you can see where one match ends and the next begins; a thin bar marks a zero-length match between characters.
Groups
Every capture group of every match, by number and by name for named groups. ∅ means the group did not take part in that match, which is different from matching an empty string.
Replace preview
The full text after replacement. $1, $<name> and $& refer to the current match; with g, every match is replaced, otherwise only the first.
Checks
Red means the pattern will not run. Amber means it runs but probably does not do what it would in PHP, Nginx or Python. The last line says whether the same pattern is valid RE2 for Go, GA4 and BigQuery.
JavaScript code
The pattern as a literal with forward slashes escaped, plus a matchAll or exec loop, so you can paste it straight into your code.
Regex flavours differ in small ways. A pattern that matches here will behave the same in any modern JavaScript runtime, but test again in the target tool if you move it to PHP, Python, Java, .NET or a database.
Four steps from idea to working pattern
Start from a preset if one is close, then adjust.
-
1
Paste real text
Use a few lines of the actual data, including lines that should not match. Testing only the happy path is how bad patterns reach production.
-
2
Write or pick a pattern
Type it without slashes, or click a preset such as Email or Date. Pasting /…/gi also works: the flags are read from the literal.
-
3
Check flags and groups
Add g to see all matches, i to ignore case, m when ^ and $ should work per line. Read the group columns to confirm each part captures what you expect.
-
4
Preview the replacement
Type a replacement such as
$<day>/$<month>/$<year>, check the preview, then copy the JavaScript code.
JavaScript regex vs PCRE, Python and RE2
Most syntax is shared: character classes, quantifiers, groups, alternation, \d \w \s, lookahead. The differences are in anchors, named groups, inline flags and a few PCRE-only features. The checks in the tester flag each of the rows below.
- Named groups: JavaScript (?<name>…), Python (?P<name>…); PCRE accepts both
- Start and end of text: JavaScript ^ and $ without m; PCRE and Python also have \A and \z
- Flags go after the closing slash in JavaScript; PCRE and Python also allow (?i) at the start
- Lookbehind: JavaScript allows any length, PCRE and Python only fixed length; RE2 has no lookaround at all
- Possessive quantifiers, atomic groups, recursion and conditionals are PCRE features with no JavaScript equivalent
| Feature | JavaScript | PCRE (PHP, Nginx) | Python re | RE2 (Go, GA4) |
|---|---|---|---|---|
| Named group | (?<n>…) | Both forms | (?P<n>…) | Both forms |
| Backreference | \1, \k<n> | \1, \k<n> | \1, (?P=n) | Not supported |
| Lookbehind | Any length | Fixed length | Fixed length | Not supported |
| Text anchors | ^ $ (no m) | \A \z \Z | \A \Z | \A \z |
| Inline flags | Scoped (?i:…) in new engines | (?i) | (?i) | (?i) |
| Unicode property | \p{L} with u or v | \p{L} | Not in re | \p{L} |
| Possessive / atomic | No | Yes | Yes (3.11+) | No |
Reformat ISO dates with named groups
The default example turns 2026-11-27 into 27/11/2026. Here is what each piece of the pattern does.
| Part | Means | In “2026-11-27” |
|---|---|---|
(?<year>\d{4}) | Exactly four digits, saved as the group “year” | 2026 |
- | A literal hyphen | - |
(?<month>\d{2}) | Two digits, saved as “month” | 11 |
(?<day>\d{2}) | Two digits, saved as “day” | 27 |
Flag g | Find every date, not just the first | 3 matches in the example |
Replacement $<day>/$<month>/$<year> | Rebuild the date from the named groups | 27/11/2026 |
20261127 and 2026/11/27 in the example do not match because the pattern requires hyphens. Add \b at both ends to avoid matching inside longer numbers such as 12026-11-271.
Why a pattern works here but not in production
Most regex bugs are one character in the wrong place, or a flavour difference.
Unescaped dot
example.com also matches exampleXcom: a bare dot means any character. Write example\.com.
Greedy .*
<.*> on <b>hi</b> matches the whole string. Use the lazy .*? or a negated class such as [^>]*.
Forgetting g or m
Without g, replace changes only the first match. Without m, ^ and $ ignore line breaks inside the text.
Catastrophic backtracking
Nested quantifiers such as (a+)+$ can take seconds or hang on a long non-matching line. This tester stops at 1.5 s; production code does not.
Fewer regex rules to maintain
Many analytics regexes exist only to sort traffic into channels or to group page paths. TapCub does the channel part for you as each visit arrives.
Sources with AI assistants built in
ChatGPT, Perplexity, Claude, Gemini, DeepSeek, Kimi and others get their own channel without any custom rule.
Learn moreMarketing analytics
Channel ROI and attribution on the same visitor data, with UTM campaigns side by side.
Learn moreSegments
Rule-based and RFM segments in product analytics, updated continuously, so groups are defined once instead of re-typed as filters.
Learn moreRegex tester questions
Still have a question?
Chat with the team behind TapCub — we usually reply within a few hours on business days.
Which regex flavour does this tester use?
JavaScript (ECMAScript), running in your own browser’s engine: V8 in Chrome and Edge, JavaScriptCore in Safari, SpiderMonkey in Firefox. Results match what RegExp, String.match, matchAll and replace do in your code and in Node.js. For GA4, BigQuery or Go, which use RE2, use the GA4 regex tester instead.
Can I test PHP (PCRE) or Python patterns here?
Mostly. The common syntax is the same, and the checks flag the constructs that differ: (?P<name>…), \A and \z, (?i) at the start, possessive quantifiers, atomic groups, recursion and POSIX classes such as [[:digit:]]. After fixing those, test once more in the target language.
How do named capture groups work in JavaScript?
Write (?<name>…). The value is available as match.groups.name, as $<name> in a replacement and as \k<name> later in the same pattern. Named groups are also numbered, so $1 still works. The match table shows both.
Why does my pattern only find one match?
The g (global) flag is missing. Without it, exec, match and replace stop at the first match. Add g in the flags box. For matchAll and replaceAll, JavaScript requires g and throws an error otherwise.
What is the difference between the m and s flags?
m (multiline) makes ^ and $ match at the start and end of every line. s (dotAll) lets . match line breaks, which it otherwise skips. They are independent; you often want neither, sometimes both.
Why did the tester stop my pattern?
It took more than 1.5 seconds, which almost always means catastrophic backtracking: nested quantifiers like (a+)+ or (.*,)* try exponentially many ways to fail on a line that does not match. Make each part more specific, or remove one level of repetition. The same pattern could freeze a browser tab or tie up a server, which is why the tester runs it in a separate worker.
Is my text sent anywhere?
No. The pattern runs in a Web Worker inside your browser; nothing is uploaded and TapCub does not store it. Share links contain only the pattern, flags and replacement, never the test text.
How do I match an email, URL or IP address?
Click the Email, URL or IPv4 presets for a starting point and adjust them to your data. Regex can check the shape of an address but not whether it exists; for email lists, the email validator also checks typos and MX records, and the email extractor pulls addresses out of text.
Is this tool working for you?
Rate it, or tell us what went wrong and what you’d like improved. A person reads every message, and frequent requests go into the next update.
Need help right now?
Chat with our support team, best for urgent problems; you can leave a message when we are offline.
Chat with supportUpdate history
New features, fixes and data refreshes for this tool, newest first.
-
· v1.0
LaunchedFirst release.
Missing something or found an error? Tell us — requests that come up often go into the next update. All tool updates
Recommend this tool in an article or on your site
This tool is free to cite and share. Copy the URL or link below into your article, tutorial or resource page; to write a review, embed a tool or partner with us, get in touch.
https://tapcub.com/tools/regex-tester<a href="https://tapcub.com/tools/regex-tester">Regex tester (JavaScript) - TapCub</a>See channels without writing regex
TapCub classifies search, social, AI assistants, email and paid traffic on arrival, and keeps bots out of the numbers.