Regex Tester
Test regex patterns against text with bounded safe execution.
Test regex patterns against text with bounded safe execution. Enter your numbers and get an instant result.
Write a regular expression, choose the g, i and m flags, and paste the text to test it against. The page lists every match with its position and its capture groups, and highlights each match inside the subject.
It runs your pattern with the browser's own RegExp engine, synchronously, with no time limit. A pattern that backtracks heavily can therefore freeze the tab, so test a risky pattern on a short sample first rather than on a large document.
Nothing is sent anywhere: the pattern, the flags and the subject all stay in this tab, and the page works with the network down once loaded.
Reading the three output panes
The match list numbers every hit and reports the matched text, the character index where it starts and its length. Nested groups appear under the match that produced them.
The highlighted view marks the subject text where the matches fall, which is the quickest way to see that a pattern is matching more than you intended.
A pattern the engine cannot compile stops the run and shows the engine's own syntax error instead of a partial result.
- g finds every match rather than the first
- i makes the match case-insensitive
- m makes ^ and $ match at line boundaries
Patterns that behave differently than expected
The engine is JavaScript's, so the dialect is ECMAScript regular expressions: lookbehind is supported in current browsers, but named-group syntax and Unicode property escapes depend on the browser version rather than on this page.
A greedy quantifier such as .* takes as much as it can and then gives characters back, which is why .* followed by a closing tag often spans several tags. A lazy .*? takes as little as it can.
Without the m flag, ^ and $ match only the start and end of the whole subject, not of each line. That single omission explains most "it matched nothing" reports on multi-line input.
How to use the pattern and subject
Type the pattern into the Regular Expression box and the text into the Test Subject Text box, then set the flags: g for every match rather than the first, i to ignore case, m so caret and dollar match at line boundaries. The match list numbers every hit with its text, index and length, the highlighted view marks the subject, and Capture Group Breakdown holds each group's value.
A pattern the engine cannot compile stops the run with the engine's own syntax error. Test a risky pattern on a short sample first: the browser RegExp engine runs synchronously with no time limit, so a backtracking pattern can freeze the tab, and multi-line input without m matches almost nothing.
What to Expect
Best for
- Checking a pattern against real sample text before shipping it
- Seeing which capture group holds which part of a match
- Explaining why a pattern over-matches on multi-line input
Not ideal for
- Parsing HTML or JSON, which need a parser rather than a pattern
- Very large subjects, where a costly pattern can hang the tab
- Dialects other than ECMAScript, such as PCRE-specific constructs
What this tool keeps
- The exact pattern text you typed, including escapes
- Match order as the engine reports it, left to right
- Capture group values for every match that has groups
What may need cleanup
- Patterns written for another dialect, which must be translated to ECMAScript
- Empty matches, which are reported and then skipped forward to avoid an endless loop
- Unicode-heavy text, where character indices count UTF-16 code units, not visible characters
Common errors
- Forgetting the g flag and wondering why only one match is listed
- Forgetting the m flag and expecting ^ to match each line
- Writing a nested quantifier that backtracks catastrophically on a long subject
Example use cases
- Validating an email or URL pattern against real addresses
- Extracting the parts of a log line into named groups
- Testing a find-and-replace pattern before using it in an editor
Sample input
Use ([a-z0-9._-]+)@([a-z0-9.-]+\.[a-z]{2,}) with g and i, and paste two sentences containing two email addresses.
Sample output
Two matches, each with the address, its start index and the two capture groups holding the local part and the domain.
Who this is for
- Developers writing a validation pattern
- Anyone debugging a find-and-replace rule
- Support engineers pulling fields out of a log line
Frequently asked questions
Which regex dialect does this tester use?
It uses the browser's ECMAScript engine with the g, i and m flags, so a pattern written for PCRE has to be translated first.
Can I use it to parse HTML or JSON?
It is not the right tool for either. Those need a parser, and a costly pattern over a very large subject can hang the tab.
Why do the reported positions differ from the visible characters?
Indices count UTF-16 code units, so an accented character or an emoji outside the basic plane can count as more than one visible character.
Build custom tools for your store
Join the SDK program to create useful ecommerce utilities for your store.