Regex Tester
Test regular expressions live, highlight every match, and understand what they do.
- Free forever
- No sign-up
- Runs in your browser
Pattern
Test string
Matches highlighted
0 matches
Replace
$1, $<name>, or $& for the whole match.The result of applying your replacement appears here.Quick reference
.Any character except newline\dDigit (0–9)\wWord character (a–z, A–Z, 0–9, _)\sWhitespace (space, tab, newline)\bWord boundary^ $Start / end of line (or string)* + ?0+ / 1+ / 0 or 1 (greedy)*? +?Lazy versions (as few as possible){2,4}Between 2 and 4 repetitions[abc]Any one of a, b or c[^abc]Any character except a, b or c(…)Capture group(?:…)Non-capturing group(?<name>…)Named capture groupa|ba or b (alternation)(?=…)Lookahead(?<=…)LookbehindWhat is a regex tester?
A regular expression — regex for short — is a compact pattern language for finding, validating and transforming text. It powers search-and-replace in editors, form validation, log parsing and countless data-cleaning scripts. The trouble is that regex is notoriously hard to read and easy to get subtly wrong. A regex tester gives you a fast feedback loop: you type a pattern, paste some sample text, and immediately see what matches and what does not.
This tool runs the pattern against your test string live using your browser's built-in JavaScript engine. Every match is highlighted in place, listed with its position and captured groups, and you can preview a replacement before committing it anywhere. Because it is 100% client-side, you can throw real data at it — log lines, emails, IDs — without anything leaving your device.
How to use it
- Type your pattern in the input between the slashes. You do not include the slashes yourself — they are just visual delimiters.
- Toggle the flags you need (explained below). Global is on by default so you see every match, not just the first.
- Paste your test string in the textarea. As you type, matches light up in the highlighted preview.
- Read the match list to confirm each match's index and inspect numbered and named capture groups.
- Add a replacement to see the result of a search-and-replace, then copy it — or drop the original and rewritten text into a text diff to review every change at a glance.
- Hit Sample to load a working email pattern if you want a starting point, or Clear to reset.
If your pattern is invalid, the exact engine error appears under the input instead of silently failing — so a stray bracket or bad quantifier is easy to spot.
Flags, explained
Flags change how the whole pattern behaves. This tester supports all six JavaScript flags:
- g (global) — find every match, not just the first. Almost always what you want when scanning a block of text.
- i (ignore case) — make the match case-insensitive, so
catalso matchesCatandCAT. - m (multiline) — make
^and$match at the start and end of each line, not just the whole string. - s (dotall) — let
.match newline characters too, which it normally does not. - u (unicode) — enable full Unicode handling, needed for
\u{...}escapes and proper emoji/astral-plane matching. - y (sticky) — anchor each match to the current position, useful for tokenizers that must match contiguously.
Capture groups vs non-capturing groups
Parentheses group part of a pattern, but they do two different jobs:
- Capturing group
(…)remembers what it matched so you can reference it later — in the match list, in a replacement ($1), or in code. Use these when you need the captured text. - Non-capturing group
(?:…)groups for structure only and does not store the result. Use these when you only need grouping for alternation or quantifiers and do not want the overhead or the extra numbering.
You can also name a group with (?<name>…) and reference it as $<name> in a replacement. Named groups make complex patterns far more readable than counting positions.
Lookahead and lookbehind
Lookarounds assert that something does or does not appear, without consuming it:
- Positive lookahead
X(?=Y)— matchXonly if followed byY. - Negative lookahead
X(?!Y)— matchXonly if not followed byY. - Positive lookbehind
(?<=Y)X— matchXonly if preceded byY. - Negative lookbehind
(?<!Y)X— matchXonly if not preceded byY.
A classic use is inserting thousands separators or validating a password has a digit without including that digit in the match. Lookbehind is supported in modern browsers; if you target older environments, test there too.
Common patterns (and their limits)
These show up constantly, but every one comes with caveats — treat them as starting points, not gospel:
- Email:
[^\s@]+@[^\s@]+\.[^\s@]+catches the vast majority of addresses. A fully RFC-compliant email regex is enormous and rarely worth it; for sign-up forms, a loose check plus a confirmation email beats a perfect pattern. - URL:
https?:\/\/[^\s]+grabs most links in text, but real URL validation has many edge cases (ports, auth, unicode hosts). For strict needs, use the browser'sURLconstructor instead. - Numbers:
-?\d+(\.\d+)?matches integers and decimals. Watch out for scientific notation and locale-specific separators. - Whitespace cleanup:
\s+with the global flag collapses runs of spaces, tabs and newlines.
The lesson: regex is excellent at recognizing shapes, but it should not be the only line of defense for anything security- or correctness-critical — and for routine transforms like turning a title into a URL-safe slug, a purpose-built tool beats a brittle pattern.
Tips for writing maintainable regex
- Start small and grow. Match the simplest case first, confirm it, then add complexity one piece at a time using the live preview.
- Prefer character classes over alternation when matching single characters —
[abc]is clearer and faster than(a|b|c). - Use named groups for anything you will reference later; future-you will thank present-you.
- Anchor when you mean it. If a value must be the entire string, wrap it in
^…$so a partial match cannot sneak through validation. - Beware greedy quantifiers.
.*grabs as much as possible; switch to the lazy.*?when you want the shortest match, for example inside tags or quotes. - Comment complex patterns in your code even though regex itself has no inline comments in JavaScript — a one-line note saves hours later.
Private and login-free by design
Many popular regex sites gate saving, history or sharing behind an account and wrap the editor in ads and trackers. Pageonaut takes the opposite approach: the tester is free, requires no sign-up, and computes everything locally with your browser's own engine. There is nothing to upload and nothing stored, so you can test patterns against production-shaped data with a clean conscience. Build the pattern, copy what you need, and close the tab.
Frequently asked questions
Comet's got your back
Stuck on something? Every tool has a short guide and FAQ — and Comet can point you to the right spot.
Visit help centreRelated tools
All Developer tools →Text Diff Checker
Compare two texts and see exactly what changed — line by line or word by word.
DeveloperSlug Generator
Turn any title into a clean, URL-friendly slug — lowercase, hyphenated, accent-safe.
SEO & WebJSON Formatter
Format, beautify and minify JSON with instant validation — all in your browser.
Developer