How to use the Regex Tester
- Type a pattern without slashes, or pick one from Insert a common pattern. Pasting a literal such as
/ab+c/gifills in the flags too. - Tick the flags you need: g for every match, i to ignore case, m for line-by-line anchors and so on.
- Paste your test text. Matches are highlighted as you type, and the table lists each one with its position and capture groups.
- Type a replacement using
$1or$<name>to preview the result, then copy it or copy the pattern for your code.
Features
- Live highlighting of every match as you type
- Capture groups, named groups and group positions with the d flag
- Replace preview with $1, $<name> and $& substitutions
- All JavaScript flags: g, i, m, s, u, y and d
- Ready-made patterns for emails, URLs, phones, dates, IPs and colors
- Runs in a background worker with a time limit, so a slow regex never freezes the page
What a regex tester is for
Regular expressions are compact patterns for finding and transforming text: pulling email addresses out of a document, validating a form field, renaming files or rewriting dates. They are also easy to get subtly wrong. A tester lets you try a pattern against real examples and see exactly what it matches before you put it into code. This one uses the JavaScript (ECMAScript) regex engine built into your browser, the same engine that runs RegExp in web pages and Node.js. Patterns written for PCRE, Python or Java are mostly compatible, but details such as lookbehind support and flag names can differ.
The flags
| Flag | Name | Effect |
|---|---|---|
g | global | Find every match instead of stopping at the first |
i | ignore case | a also matches A |
m | multiline | ^ and $ match at each line, not just the whole text |
s | dot all | . also matches line breaks |
u | Unicode | Treats emoji and other astral characters as one character and enables \p{…} |
y | sticky | Each match must begin exactly where the previous one ended |
d | indices | Records the start and end position of every capture group |
Capture groups and replacements
Parentheses capture the text they match, numbered from left to right by their opening parenthesis. You can name a group with (?<year>\d{4}) to make patterns self-documenting. In the replacement, $1 inserts group 1, $<year> inserts a named group, $& inserts the whole match and $$ writes a literal dollar sign. For example, the pattern (\d{4})-(\d{2})-(\d{2}) with the replacement $2/$3/$1 turns 2026-03-14 into 03/14/2026.
Greedy versus lazy
Quantifiers such as * and + are greedy: they grab as much as they can and give characters back only when the rest of the pattern needs them. Against <b>one</b> and <b>two</b>, the pattern <b>.*</b> matches the entire line in one go. Adding a question mark makes it lazy: <b>.*?</b> stops at the first closing tag and finds two separate matches.
Catastrophic backtracking
When a pattern can match the same text in many different ways, a failed match may force the engine to try every combination, and the work grows exponentially with the length of the input. The classic example is ^(a+)+$ tested against a long run of a’s followed by an exclamation mark. In a web page or a server, that can lock up the browser tab or a request handler; this vulnerability is known as ReDoS. Here the matching runs in a separate worker and is stopped after 1.5 seconds, with a warning. To fix such a pattern, avoid quantifiers nested inside other quantifiers, make alternatives mutually exclusive and anchor the pattern where you can.
Validation patterns are approximations
The ready-made patterns are practical rather than exhaustive. No reasonable regex fully implements the email address grammar, so the email pattern accepts the addresses people actually use; the only real test is sending a message. The IPv4 pattern checks that each part is between 0 and 255, and the date pattern checks ranges but not whether February 30 exists. For bulk extraction from documents, try the Email Extractor, and for simple search and replace without patterns, use Find and Replace.
Frequently asked questions
Which regex flavor does this tester use?
JavaScript (ECMAScript), as implemented by your browser. Current browsers support lookbehind, named groups, the s, u, y and d flags, and Unicode property escapes such as \p{L}.
Why is only one match highlighted?
The g (global) flag is off. Without it, JavaScript stops after the first match. Tick g to find every match.
Why does ^ not match at the start of each line?
By default ^ and $ refer to the start and end of the whole text. Tick the m (multiline) flag to make them match at every line break.
What does “Stopped after 1.5 seconds” mean?
The pattern took too long on your text, almost always because of catastrophic backtracking from nested quantifiers like (a+)+. The page stays responsive because the matching runs in a background worker that is stopped.
Do I need to escape forward slashes?
Not in the pattern box. Slashes only need escaping inside a regex literal in code, such as /https?:\/\//. The Copy as /regex/ button gives you the literal form.
Is my test text sent anywhere?
No. Matching runs in your browser, and the last pattern and text are only remembered in this browser’s local storage.