Regex Tester
Build a regular expression against real sample text and see every match and capture group as you type.
Your data stays on your device
Test text
- characters
- 0
- lines
- 0
- size
- 0 B
Matches (0)
Enter a pattern to begin.
Uses the JavaScript regular expression engine. Patterns validated here should still be tested in your target language — PCRE, Python and Go differ in lookbehind support, escapes and named group syntax.
About this tool
Regular expressions are written by iteration. You try a pattern, look at what it matched, and adjust — which is painful when the only feedback is whether your program crashed. A live tester collapses that loop to a few seconds.
Matches are highlighted in the sample text and listed with their position, full match and every capture group, including named groups. A replacement field lets you preview a substitution before committing it to code.
How to use this tool
- Enter your pattern, without the surrounding slashes.
- Toggle the flags you need: g, i, m, s and u.
- Paste sample text — matches highlight immediately as you type.
- Optionally enter a replacement string to preview the substituted result.
Key features
- Live highlighting as you type the pattern or the text
- Match list with index, length, full match and all groups
- Named capture groups shown by name
- Standard flags: global, ignore case, multiline, dotAll and unicode
- Replacement preview supporting $1 and named group references
- Invalid patterns reported with the syntax problem instead of failing silently
Example
Input — Pattern + text
pattern: (?<y>\d{4})-(?<m>\d{2}) text: due 2026-07Output — Matches
match "2026-07" at 4
y = 2026
m = 07Good to know
- This uses the JavaScript regex engine. PCRE, Python and Go features such as lookbehind support and possessive quantifiers differ.
- Catastrophic backtracking is possible with nested quantifiers; a guard stops runaway evaluation and warns you.
- Very large sample texts slow down live evaluation, so matching is debounced.
Frequently asked questions
Why does my pattern behave differently in Python?
Engines differ in syntax and semantics. Named groups, lookbehind and escape handling all vary, so a pattern validated here should still be tested in your target language.
What does the g flag change?
Without it only the first match is found. With it, matching continues through the whole string, which is what you want when listing all occurrences.
How do I reference a capture group in a replacement?
Use $1, $2 and so on for numbered groups, or $<name> for named groups. The preview shows the result immediately.
Why did evaluation stop with a warning?
The pattern likely triggers catastrophic backtracking — typically nested quantifiers over a long string. Simplify the pattern or anchor it.
Your data stays on your device
Your data is processed locally in your browser and is not uploaded to our server. This page keeps working after you go offline, because there is nothing to send.