Regex Tester — Test Regular Expressions with Live Matching
Test regular expressions with live matching. Highlight matches, view capture groups, and explain patterns — runs in your browser, no upload.
Regular expressions are the most powerful string-processing tool ever invented and the most frequently miswritten code in every programming language. A regex that matches exactly what you intended on your test input but over-matches or under-matches in production is a bug that a visual tester catches in seconds and a code review might never notice. The tester shows every match in context — the matched substrings highlighted in the source text, the capture groups labelled and extracted, and the unmatched text clearly separated — so the difference between [a-z]+ and [a-z]+$ is visible before the pattern reaches production.
The regex explainer is the tool’s most distinctive feature. Regex syntax is famously write-only: a pattern that made sense when you wrote it can be incomprehensible six months later when you need to modify it. The explainer decomposes the pattern into its constituent tokens and writes a plain-English description of each one: quantifiers, character classes, anchors, groups, alternations, and lookarounds. This makes the tool equally useful for reading regex as for writing it — paste a pattern from a colleague’s pull request, hit explain, and understand what it does before you approve.
The flavour selector addresses the most painful regex interoperability problem: the same pattern can produce different matches in different languages because the regex engine implementations differ. JavaScript lacks possessive quantifiers and lookbehind (before ES2018). Go’s regexp package disallows backreferences. Python’s re module handles Unicode character classes differently than JavaScript. The tester lets you switch between flavours to see how each engine interprets the pattern, which surfaces cross-language differences before you commit to a pattern that works in your local environment but fails in CI.
How to use
Write a regex pattern
Type a regular expression in the pattern input. Choose a flavour: JavaScript (browser-native), PCRE, Python, or Go. The tester shows syntax errors inline as you type, before any matching occurs.
Paste test text
Paste the text you want to match against in the text panel. Matches are highlighted in real time as you edit either the pattern or the text. Each match is rendered with a distinct background colour, and overlapping matches are visually distinguished.
Inspect capture groups
Click any match to see the full match and each numbered capture group displayed in a side panel. Named capture groups are labelled with their name. Zero-length matches are shown as a thin cursor bar at the match position.
Frequently asked
What's the difference between the regex flavours?
JavaScript flavour uses the browser's built-in RegExp engine (ECMAScript spec, no lookbehind in older browsers). PCRE flavour enables lookbehind assertions and possessive quantifiers. Python flavour adds `\A`/`\Z` anchors. Go flavour disallows backreferences and lookarounds. Choose the flavour that matches your target runtime.
How does the explainer work?
The regex explainer deconstructs the pattern token by token and writes a plain-English description of each component. `^\d{3}-\d{2}-\d{4}$` becomes 'start of line, exactly 3 digits, hyphen, exactly 2 digits, hyphen, exactly 4 digits, end of line'. This is the right tool when you inherit a regex you did not write.
Why does my pattern match differently than expected?
Common gotchas: missing start-of-string (^) or end-of-string ($) anchors allow partial matches. Quantifiers are greedy by default (`.*` eats the whole string). Character classes like `[a-z]` do not match accented letters. The tester shows the full match span and any unmatched text, which helps diagnose over- or under-matching.
Can I save or share my test case?
The pattern and test text are encoded in the URL fragment, so bookmarking the page or sharing the URL preserves the current state. No data is sent to a server — the encoding is purely client-side URL fragment serialisation.
Does it support Unicode property escapes?
Yes — `\p{Letter}`, `\p{Number}`, `\p{Script=Greek}`, and other Unicode property escapes are supported in the JavaScript flavour (ES2018+). The tester validates the syntax against the selected flavour and flags unsupported escapes.
Limitations
- Flavour accuracy is best-effortThe regex engine is the browser's native JavaScript RegExp for all flavours. Differences in backtracking behaviour, Unicode handling, and edge-case quantifier semantics between languages are documented in the flavour notes but not emulated.
- Catastrophic backtracking is not preventedPatterns that trigger exponential backtracking can freeze the browser tab. The tester warns on patterns with nested quantifiers (e.g., `(a+)+b`) but does not interrupt execution. Save your work before testing suspect patterns.
- No replacement/substitution modeThe tester validates matches and capture groups but does not provide a replacement mode. For search-and-replace testing, use the text-diff or string-replace capabilities of your code editor.
Platform notes
- macOS
- BBEdit and VS Code have built-in regex testers for file search. The browser tool is the right pick for testing a regex against ad-hoc text from a chat, email, or API response.
- Linux
- For command-line testing, `echo 'text' | grep -P 'pattern'` tests PCRE regex. The browser tool adds the capture-group visualiser and the multilingual flavour toggle.
- Web
- Runs entirely client-side. Regex and test text stay on your device.