Regex Tester
Test regular expressions with live match highlighting.
g— find every match, not just the firsti— match letters regardless of casem— ^ and $ match at line breakss— . also matches newline charactersu— treat the pattern as Unicode code pointsy— match only from lastIndex onward
How to use Regex Tester
What this tool does
A regex tester lets you write a regular expression and instantly see what it
matches against a sample of text. You type a pattern, choose flags with
checkboxes, and paste a test string; the tool builds a RegExp, runs it, and
shows three things at once — the total number of matches, a detailed list of
each match with its index and capture groups, and your text re-rendered with
every match highlighted. If the pattern is invalid, a clear error explains why
instead of leaving you guessing. Everything runs locally in your browser.
Why you might need it
Regular expressions are powerful but unforgiving: a single misplaced quantifier or an unescaped dot changes the result completely. Testing a pattern by editing code, re-running it, and reading console output is slow. A live tester closes that loop — you change one character of the pattern and immediately see the effect on real input. It is the fastest way to build a pattern for validating an email field, extracting values from log lines, finding every URL in a document, or writing a find-and-replace rule with confidence before you ship it.
How to use it
- Type your pattern into the Regular expression box (without the surrounding slashes).
- Tick the flags you need —
gto find every match is on by default. - Paste the text you want to test into the Test string box.
- Read the match count, then switch between Highlight and Match list to inspect the results.
- Use one of the Examples buttons for a ready-made starting point.
Common pitfalls
The most common surprise is forgetting the g flag. Without it, only the first
match is found, so a pattern that looks correct seems to miss everything after
the first hit. Another is escaping: inside this tool you type the raw pattern,
so a literal dot is \. and a literal backslash is \\. Character classes
also trip people up — [a-z] matches one lowercase letter, and adding +
makes it match one or more.
Anchors behave differently with the m flag. By default ^ and $ match only
the very start and end of the whole string; with m they also match at every
line break. If your pattern can match an empty string — for example a* — a
global scan would normally loop forever, but this tool advances past
zero-length matches automatically so the result is still correct.
Tips and advanced use
Use capture groups to pull structured data out of text: wrap the parts you want
in parentheses and read them back in the match list. Named groups like
(?<year>\d{4}) work too. When you only care about grouping and not capturing,
use a non-capturing group (?:...) to keep the match list clean.
Turn on the i flag for case-insensitive matching, s so that . also spans
newlines, and u when your pattern uses Unicode escapes or needs to handle
characters outside the basic plane. Because the JavaScript engine differs in
small ways from PCRE and other flavours, always test a pattern here before
relying on it — and since nothing leaves your device, it is safe to do that
with production log samples or other sensitive text.
Frequently asked questions
Is my test string sent anywhere?
Which regex syntax does this support?
Why does my pattern with the g flag match the same spot forever?
How do I see capture groups?
What is the difference between the highlight and list views?
Related tools
UUID Generator
Generate v1 and v4 UUIDs in bulk.
ULID Generator
Generate sortable, time-based ULIDs.
Hash Generator
Generate MD5, SHA-1, SHA-256, and SHA-512 hashes.
HMAC Generator
Generate HMAC signatures with the Web Crypto API.
HTML to Markdown
Convert HTML into clean Markdown.
Markdown to HTML
Convert Markdown into HTML.