Regex Tester: test regular expressions online
Use the Regex Tester to test regular expressions online against your browser's JavaScript engine. Matches are highlighted and listed with their positions and capture groups. For example, \b([\w.-]+)@([\w-]+\.[a-zA-Z]{2,})\b finds 2 email addresses in contact text, including their names and domains. Your pattern and text never leave your browser.
Built by Jakub Martyniak
Shipping this pattern? Run your app on a VPS with full root access.
Input
Result
Enter a pattern on the left to see matches.
Example result
What a result looks like in the Regex Tester
You enter a pattern and some text, and the tool lists every match with its position and capture groups. In replace mode, it shows the text after replacement. The example below uses fictional addresses; your matches depend on your pattern and text.
Example · g flag (all matches)
2 resultsInput
- Pattern
- \b([\w.-]+)@([\w-]+\.[a-zA-Z]{2,})\b
- Group 1 captures the part before the @, group 2 the domain.
- Test text
- info@example.com, support@example.org, no-at.example.net
Output
- Match 1
- info@example.com
- Index 0 · Group 1: info · Group 2: example.com
- Match 2
- support@example.org
- Index 18 · Group 1: support · Group 2: example.org
- Replace with $1 [at] $2
- info [at] example.com, support [at] example.org, no-at.example.net
- The address without @ is not recognized and remains unchanged.
Why this tool
More than just a match test
An overview of the Regex Tester's key features.
Matches highlighted and counted
After a short pause in typing, the tool counts all matches and highlights them in the result—or the first 1000 if there are many.
Monitor capture groups
Each match appears in a list with its index, followed by its numbered and named capture groups.
Flags g, i, m, s, and u
Toggle the five flags with checkboxes; they work just as they do in JavaScript code. g is enabled by default.
Replacement mode
Replaces matches using String.prototype.replace() with $1, $2 for capture groups. Copy the result with one click.
Protection against catastrophic backtracking
Evaluation runs in a Web Worker and stops after 1 second so a pattern like (a+)+ doesn't freeze the tab.
Runs only in the browser
Pattern and test text are processed entirely client-side—nothing is sent to a server.
Guide
How to test regular expressions online
From pattern to copied result: how to use the Regex Tester.
Step 1
Select mode
Select “Find matches” above to inspect matches, or “Replace” to replace text.
Step 2
Enter a pattern
Enter your regular expression without slashes in the “Pattern” field, or use “Load example” to load an email pattern and sample text.
Step 3
Set flags
Toggle the g, i, m, s, or u flags with the checkboxes. g is enabled by default; active flags appear after the pattern, e.g. /g.
Step 4
Insert test text
Paste your text into the “Test Text” field. After a short pause in typing, matches are highlighted in the result and counted above.
Step 5
Review and copy matches
The match list shows each match with its index and capture groups. Use the copy button to copy all matches, one per line.
Step 6
Replace and copy the result
In “Replace” mode, enter the new text in the “Replace with” field, using $1, $2 for capture groups, then copy the result with the copy button.
Cheat sheet
Regex cheat sheet: the essentials
A regular expression (regex) is a search pattern for text. You can use it to find, validate, extract, or replace strings such as email addresses, dates, or log entries. Try these JavaScript syntax elements directly in the Regex Tester above.
| Token | Meaning |
|---|---|
| . | Any character except a newline; with the s flag, newlines too |
| \d | A digit from 0 to 9 |
| \w | Word character: only A–Z, a–z, 0–9, and _, not letters such as ä, é, or ñ |
| \s | Whitespace such as a space, tab, or newline |
| \p{L} | Any letter, including accented letters, only with the u flag |
| \b | Word boundary, e.g. \bRegex\b to match that exact word |
| ^ $ | Start and end of text; with the m flag, of each line |
| [abc] | One of the characters a, b, or c |
| [^abc] | Any character except a, b, or c |
| a|b | a or b |
| * + ? | Zero or more, one or more, zero or one occurrence |
| {2,5} | Two to five repetitions |
| .*? | Adding ? makes the quantifier lazy: as few characters as possible |
| ( … ) | Capture group, listed as group 1, 2, etc. in the Regex Tester |
| (?<name> … ) | Named capture group, also listed by name in the Regex Tester |
| (?: … ) | Non-capturing group, e.g. for alternatives or quantifiers |
| (?= … ) (?! … ) | Lookahead: only if … follows or does not follow |
| \. | A backslash before a special character matches it literally, e.g. \. for a period |
Discover more
More tools
Compare text online (Diff Checker)
Compare text online: Compare two texts, configs, or code versions, see differences line by line and word by word, and copy them as a Unified Diff. Runs entirely in your browser.
Built by Dimitri Heissler
JSON Formatter
Format, minify, and validate JSON with syntax highlighting, error messages, and downloads, entirely in your browser.
Built by Jakub Martyniak
YAML Validator
Check YAML syntax and format it consistently or convert it directly to JSON. Supports multiple documents separated by `---` (e.g., Kubernetes manifests), with precise line and column error messages. Runs entirely in your browser.
Built by Jakub Martyniak
Crontab Generator
Build Cron expressions using a form, with plain-language explanations and a preview of upcoming execution times—all in your browser.
Built by Jakub Martyniak
URL Encoder & Decoder
Encode and decode URLs and text online: compare encodeURIComponent, encodeURI, and form encoding, with a query parameter table and UTM link builder. Runs entirely in your browser.
Built by Dimitri Heissler
.htaccess Generator & htpasswd Generator
Create Apache .htaccess and .htpasswd files online: 301 redirects, HTTPS, password protection with bcrypt, WordPress rules, error pages, caching, GZIP, and hotlink protection. Runs entirely in your browser.
Built by Dimitri Heissler
FAQ
Regex Tester frequently asked questions
Brief answers about regular expressions and this tool.
A list of all matches with positions and capture groups. The pattern \b([\w.-]+)@([\w-]+\.[a-zA-Z]{2,})\b finds 2 matches in “info@example.com, support@example.org, no-at.example.net”: info@example.com at index 0 and support@example.org at index 18, each with name and domain as groups 1 and 2. In replace mode, $1 [at] $2 turns this into “info [at] example.com, support [at] example.org, no-at.example.net”.
Yes. The Regex Tester is free and requires no account: open the page, enter a pattern and test text, and inspect the matches.
No. Evaluation runs in your browser, in a Web Worker using the browser's own RegExp engine. Nothing is uploaded or logged. This matters because test texts often contain real log lines or email addresses.
Your browser's native JavaScript engine (ECMAScript), using the same regex syntax as JavaScript, TypeScript, and Node.js. PCRE (PHP, Perl) and Python's re module differ in some details: JavaScript does not support \K, and named groups use (?<name>…) rather than (?P<name>…).
g (global) returns all matches and is enabled by default. Without g, the tool behaves like RegExp.exec() and returns at most one match. i ignores case, m makes ^ and $ match the start and end of each line, s lets the dot match newlines, and u enables Unicode mode, which you need for \p{L}, for example.
Switch to “Replace” mode and enter the new text in the “Replace with” field. Use $1, $2, etc. to insert capture groups, or $<name> for named groups. The tool uses String.prototype.replace(): without the g flag, only the first match is replaced. Copy the result with the copy button.
Yes. Each match shows its capture groups: numbered groups as 1, 2, etc., and named groups such as (?<jahr>\d{4}) also under their names. If a group captured nothing, it shows “(no match)”.
If a pattern is invalid, such as an unclosed bracket, the tool displays the browser engine's error message. If evaluation takes longer than 1 second, it stops. This usually means the pattern is vulnerable to catastrophic backtracking, for example due to nested quantifiers like (a+)+. Simplify the pattern or shorten the test text.
The match count is always exact. At most the first 1000 matches are highlighted and the first 200 are listed, each with its index and capture groups. If there are more than 200, a notice appears above the highlighted text.
Any more questions?
Contact SupportYour application needs a reliable server behind it
A ZAP-Hosting VPS reliably puts your application or project online.
No setup. No risk. Online in seconds.
Looking for more tools? View all developer tools
