Regex Tester
Test JavaScript regular expressions live, with matches highlighted, a match list, capture groups and replace mode. Free, no sign-up, and it runs in your browser.
Dedicated page: /en/regex-tester
Report an Issue
Found a mistake or a problem with this tool? Tell us below.
Quick answer
A regex tester lets you write a regular expression and see instantly what it matches in your text, with matches highlighted, capture groups listed and flags like global, case-insensitive and multiline explained. It is the fastest way to build and debug patterns before they go into code.
About this Regex Tester
Test JavaScript regular expressions live, with matches highlighted, a match list, capture groups and replace mode. It is one of the Developer Tools on ToolUstad, and like every tool here it runs entirely in your browser: nothing you type, paste or open is uploaded to a server, and there is no sign-up or usage limit.
What is a regular expression?
A regular expression, or regex, is a pattern language for searching text: character classes like [0-9], quantifiers like + and {2,4}, anchors like ^ and $, groups, alternation and lookarounds. Regex powers search and replace, input validation, log analysis and text extraction in almost every programming language. It is also famously easy to get subtly wrong, which is exactly why a live tester exists.
What this tester shows you
- Live highlighting of every match in your sample text as you type the pattern.
- Match list with capture groups, so you can see exactly what $1, $2 and named groups captured.
- Flags control for g (global), i (case-insensitive), m (multiline), s (dotAll) and u (unicode).
- Replace mode to preview a substitution, including $1 group references, before running it on real data.
- Presets for common patterns like email addresses, URLs, dates and IP addresses.
When and why to test a regex live
- Validation rules: confirm a pattern accepts real inputs and rejects the edge cases.
- Data extraction: pull dates, prices or IDs out of logs and scraped text.
- Search and replace: preview a bulk rename or reformat on a sample before touching real files.
- Learning: change one token at a time and watch the matches change.
Best practices
- Test against failing examples as well as passing ones: a pattern that matches everything is useless.
- Anchor validation patterns with ^ and $ so partial matches do not slip through.
- Prefer specific character classes over dot where you can: [0-9] documents intent better than .
- Beware greedy quantifiers: .* will swallow more than you expect in the middle of a string.
Common mistakes to avoid
- Forgetting to escape dots in things like IP addresses, so 1.2.3.4 also matches 1x2x3x4.
- Writing email regex that tries to implement the full RFC and rejects real addresses.
- Catastrophic backtracking from nested quantifiers on long inputs.
- Testing only in one flavour: JavaScript, Python (re) and PCRE differ in features.
Who is the regex tester for?
Developers, data analysts, system administrators reading logs, and technical writers documenting patterns. Running a pattern in your head or in a production code path is how subtle bugs ship; a tester shows the truth against your own sample text in milliseconds, and this one runs the JavaScript flavour your browser uses.
From pattern to production, safely
A pattern that works in this tester still deserves three production checks. First, performance: test it against the longest realistic input, because patterns with nested quantifiers can slow down catastrophically on adversarial text. Second, anchoring: a pattern written for searching will also match inside larger strings, so validation code usually needs ^ and $ added around the tested core. Third, flavour: copy the exact pattern into your language's engine and run your sample set once there, since Python, PCRE and JavaScript differ on a handful of features. The tester gets you a correct, understood pattern; those three checks make it a safe one.
Learn: how to use the Regex Tester
- Write a pattern, or pick a preset like email, URL or IPv4, then adjust it.
- Write or paste the test string. Matches highlight instantly and are listed with their index and capture groups.
- Toggle flags (global, ignore case, multiline, dot-all, unicode) to change behaviour. Switch on Replace mode to preview substitutions.
Features
- Live highlighting of every match in the test string
- Match table with index and all capture groups ($1, $2, ...)
- Flag toggles for g, i, m, s and u
- Replace mode with $1 group references
- Presets for email, URL, IPv4, dates, hex colours, phone and hashtags
- Clear error message the moment a pattern is invalid
Worked example
Pattern \b[\w.+-]+@[\w-]+\.[\w.]+\b on the sample text finds 2 valid email addresses and correctly ignores admin@ and @nowhere.
Frequently asked questions
Which regex flavour is this?
JavaScript's built-in RegExp engine, the same syntax used in browsers and Node.js. Most patterns from other flavours work, but lookahead support and flags differ slightly from PCRE or Python.
Why did matching stop early?
Without the g (global) flag, only the first match is returned. Enable g to find all matches.
What does $1 mean in replace mode?
It inserts the text captured by the first pair of parentheses in your pattern. $2 is the second group, and $& is the whole match.
Can a regex freeze the page?
Pathological patterns on long text can be slow (catastrophic backtracking). This tester caps collection at 500 matches, and you can always shorten the test string.
Which regex flavour does this tester use?
JavaScript's built-in RegExp engine, the same one used by browsers and Node.js. Most everyday patterns behave identically across flavours, but lookbehind, named groups and some escapes differ between JavaScript, PCRE and Python.
What does the global flag change?
Without the g flag, matching stops at the first match. With it, the tester finds every match in the text, which is what you want for highlighting, counting and extraction. Replace operations usually need g too.
How do I match a literal dot or dollar sign?
Escape it with a backslash: \. matches a real full stop and \$ matches a dollar sign. Inside a character class most escapes are unnecessary, so [.] also matches a literal dot.
Why does my pattern match more than I expected?
Usually because a quantifier is greedy or the pattern is unanchored. A pattern like [0-9]+ happily matches the digits inside 'abc123xyz' because nothing says the whole string must be digits. Add anchors ^ and $ for validation, or make the quantifier lazy with a following question mark when you want the shortest possible match between two markers.
Related tools
More Developer Tools like this one, plus two picks from other categories. Each opens its own dedicated page.