Regex Tester
Write a regular expression and see every match highlighted live, with capture groups, flags and a replace preview. Everything runs in your browser, so nothing is uploaded anywhere.
- Free
- No sign-up
- Runs in your browser
Type a pattern to start.
Matches are highlighted as you type, in alternating colours so neighbouring matches stay easy to tell apart.
Uses your browser's own JavaScript regex engine, in a background worker so a runaway pattern can never freeze the page. Your pattern and text are never sent anywhere.
What it is for
A regular expression (regex) is a small pattern language for finding text, such as every email address or date in a document. This tester runs your pattern with the same JavaScript engine your browser uses, highlights each match and lists its capture groups.
- Build a validation pattern for emails, phone numbers or postcodes and test it against real examples.
- Pull dates, IDs or URLs out of a log file or a block of text.
- Preview a find and replace before running it in your editor or code.
- Understand an existing regex by watching what it matches.
How to use it
- Type your pattern in the Regular expression box, without the surrounding slashes. Or load one of the examples.
- Switch on the flags you need: g for every match, i to ignore case, m for line-by-line ^ and $, and so on.
- Paste your text into Test string. Matches are highlighted instantly and counted above.
- Check the Match details table for positions and groups, or tick Replace to preview a substitution.
Examples
Find dates with named groups
You enter
Pattern: (?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2}) flags: g
Text: Released 2026-11-27, patched 2026-12-03.You get
2 matches
1: 2026-11-27 year "2026", month "11", day "27"
2: 2026-12-03 year "2026", month "12", day "03"Reformat with a replacement
You enter
Same pattern and text, replacement: $<day>/$<month>/$<year>You get
Released 27/11/2026, patched 03/12/2026.Use $1, $2 for numbered groups, $<name> for named groups and $& for the whole match.
Ignore case
You enter
Pattern: cat flags: gi
Text: Cat, CAT and catYou get
3 matches: Cat, CAT, catWithout the i flag only the last one matches.
Good to know
- Matches are highlighted as you type, in two alternating colours so matches that sit next to each other stay easy to tell apart.
- Named groups such as (?<year>\d{4}) appear by name in the match table and can be used as $<year> in the replacement.
- Turn off the g flag to see only the first match, exactly as String.match and RegExp.exec do without it.
- Patterns run in a background worker. If one takes more than 1.5 seconds it is stopped, so a runaway pattern never freezes your tab.
Limits and disclaimers
- This tester uses JavaScript regex syntax. Most patterns work the same in Python, PHP, Java or .NET, but some features differ, such as lookbehind support, possessive quantifiers and inline flags like (?i).
- Some patterns, such as (a+)+$, take exponential time on certain text. The tester stops them after 1.5 seconds, but the same pattern could hang your own app, so rewrite it.
- Regex is a poor fit for nested formats such as HTML or JSON. Use a real parser for those.
- The match table lists the first 500 matches, and matching stops after 5,000 to keep the page responsive.
ByteKit is provided as is, for convenience. Check any result that matters before you use it in production, and keep passwords, keys and personal data out of any website you do not control.
Regex cheat sheet
The building blocks you will use most often. Try any of them in the tester above.
| Syntax | Meaning |
|---|---|
| . | Any character except a new line |
| \d \w \s | A digit, a word character (letter, digit or _), a space |
| \D \W \S | The opposite: not a digit, not a word character, not a space |
| [abc] [^abc] [a-z] | One of these characters, none of them, or a range |
| * + ? | Zero or more, one or more, zero or one of the previous item |
| {3} {2,5} {2,} | Exactly 3, between 2 and 5, or at least 2 |
| *? +? | Lazy versions: match as little as possible |
| ^ $ | Start and end of the text (or of each line with the m flag) |
| \b | A word boundary, for whole-word matches |
| ( ) (?: ) | A capture group, and a group that does not capture |
| (?<name> ) | A named capture group, used as $<name> when replacing |
| a|b | Either a or b |
| (?= ) (?! ) | Lookahead: followed by, or not followed by |
| (?<= ) (?<! ) | Lookbehind: preceded by, or not preceded by |
- To use a pattern in code, wrap it in slashes and add the flags: /\d{4}/g. In a string, double every backslash: new RegExp("\\d{4}", "g").
- Quantifiers are greedy by default. <.+> matches from the first < to the last > on a line, while <.+?> stops at the first >.
- Avoid nested quantifiers such as (a+)+ or (.*)*. On text that almost matches, they can take exponentially long and freeze an app.
Related tools
Questions people ask
Which regex flavour does this use?
The JavaScript (ECMAScript) engine built into your browser, the same one used by Node.js, Deno and every website. Results match what new RegExp() gives in your code.
What do the flags g, i, m, s, u and y mean?
g finds all matches, i ignores case, m makes ^ and $ match at each line, s lets the dot match new lines, u turns on full Unicode support and y (sticky) only matches at the current position.
Why does my pattern match nothing?
Common causes are a missing g or i flag, forgetting to escape special characters such as . ? + ( and ), or using syntax from another language. Do not type the surrounding slashes: the box already adds them.
How do I match a literal dot or bracket?
Put a backslash before it: \. matches a dot and \( matches an opening bracket. Inside a character class like [.] most characters are literal already.
Is my text sent to a server?
No. Your pattern and text are processed in your browser and never uploaded, so it is safe to test against real logs or data.
Guides
Longer reads from the ByteKit blog that go with this tool.