Developer Tools
Regex Tester
Build and test JavaScript regular expressions against your own text with live highlighting, a match list and capture groups. Toggle flags like global, ignore-case and multiline.
Contact us at hello@alldaytoolkit.com or support@example.org.
| # | Match | Index | Groups |
|---|---|---|---|
| 1 | hello@alldaytoolkit.com | 14 | — |
| 2 | support@example.org | 41 | — |
How to test a regex against your own text
- Type the pattern between the two slashes. Leave the slashes out — they are drawn for you. The field starts with a simple email pattern so you can see a result straight away.
- Turn flags on and off with the five buttons under the pattern: g, i, m, s and u. The active flags are shown after the closing slash, just as you would write them in code.
- Paste the text to search into the Test string box. The expression is re-run on every keystroke in either box, so there is no Run button to press.
- Read the results: a match count, the text with each match highlighted, and a table listing the matches with their positions and capture groups. With g off, only the first match is shown and the label says so.
The five flags offered and what each one changes
The sticky flag y, the indices flag d and the newer v flag are not offered. The flags are handed to the engine exactly as shown after the closing slash, so turning g off is a real change rather than a cosmetic one: the search stops at the first hit, the count reads 1 or 0, and the label switches to First match only. That mirrors what exec and String.prototype.match do with a non-global expression in your own code.
| Flag | Button label | Effect in this tester |
|---|---|---|
| g | global | Finds every occurrence instead of stopping at the first. With g off the tester reports just the first match, and the label above the preview changes to First match only. |
| i | ignore case | Letters match regardless of case, so /b/i finds both b and B. |
| m | multiline | ^ and $ match at the start and end of each line, not only of the whole text. |
| s | dotall | The dot also matches line breaks, which it normally skips. |
| u | unicode | Treats the text as code points: \u{1F600} escapes work and surrogate pairs count as one character. Some sloppy escapes become errors. |
How matches are found and shown
The pattern and flags are handed to the JavaScript RegExp constructor. With g on, the expression runs in an exec loop over the test string; with g off, exec is called once and the loop ends after that first hit. Each hit is wrapped in a highlight in the preview and added to the table. An empty match (for example from the pattern a*) advances one character so a global loop can finish, and a guard stops after 10,000 matches. The table lists the first 100 matches; the count in the Matches label still reports the full total.
The Index column is the zero-based position of the match in the test string. With the default pattern \w+@\w+\.\w+ and the sample sentence, the first address hello@alldaytoolkit.com starts at index 14 and support@example.org at index 41. The Groups column joins the capture groups with commas: change the pattern to (\w+)@(\w+)\.(\w+) and the first row reads hello, alldaytoolkit, com. A pattern with no groups shows a dash, and a group that did not take part in the match shows as an empty entry. Named groups such as (?<user>\w+) are listed by position only; the name is not displayed.
Tokens you will type most often
| Token | Matches |
|---|---|
| \d \w \s | A digit; a letter, digit or underscore; any whitespace character |
| \D \W \S | The opposite of each of the above |
| . | Any character except a line break (any character at all with the s flag) |
| [a-z] [^0-9] | One character from the set; the caret negates the set |
| ^ $ | Start and end of the text (or of each line with the m flag) |
| \b | A word boundary, useful for matching whole words only |
| * + ? {2,5} | Zero or more, one or more, zero or one, between two and five repeats |
| *? +? | Lazy versions that match as little as possible |
| (x) (?:x) | A capturing group that appears in the table, and a group that does not |
| (?=x) (?!x) (?<=x) | Lookahead, negative lookahead and lookbehind, none of which consume text |
When the pattern is red
If the expression cannot be compiled, the match area is replaced by the browser's own SyntaxError text, something like Invalid regular expression: /(/g: Unterminated group. The wording differs between Chrome, Firefox and Safari, but the cause is the same: an unbalanced bracket, a quantifier with nothing before it (a pattern starting with a plus or a star), or a backslash followed by a character the engine does not recognise under the u flag. Fix the pattern and the results come back instantly.
A pattern that compiles but takes forever is a different problem. The tester runs synchronously in the page with no timeout, so a pattern prone to catastrophic backtracking, such as (a+)+$ against a long run of the letter a followed by a different character, can freeze the tab. Keep the test string short while you build a pattern with nested quantifiers.
Checking a pattern before it goes into production
- Form validation: paste a handful of valid and invalid inputs on separate lines, enable m, and anchor with ^ and $ so each line is tested on its own.
- Log mining: paste a few hundred log lines and watch the match count change as you tighten the pattern.
- Replace and split calls: the same expression object is used by String.prototype.replace and split, so what highlights here is exactly what those methods will act on.
- Analytics and firewall rules that accept JavaScript-style regex can be rehearsed here, but remember that tools built on PCRE, RE2 or POSIX differ in details such as lookbehind, possessive quantifiers and \A and \Z anchors.
Frequently asked questions
Which regex flavor does it use?
It uses the JavaScript (ECMAScript) regular-expression engine — the same one in browsers and Node.js — so results match what your JavaScript code will do.
What do the flags do?
g matches all occurrences, i ignores case, m makes ^ and $ match each line, s lets the dot match newlines, and u enables full Unicode handling.
What changes when I turn the g flag off?
The expression is compiled without g, so exec runs once and only the first match is highlighted and listed; the label above the preview reads First match only. Turn g back on to see every occurrence.
Can I test a replacement string here?
No. The tool only finds and highlights matches. Once the pattern matches what you expect, use it in a replace call in your own code or editor.
Do named capture groups work?
Yes, a pattern such as (?<year>\d{4}) compiles and matches normally. The Groups column lists the captured text in order, without the group names.
Is there a limit on the amount of text?
There is no size limit, but everything is recalculated on each keystroke and the table shows only the first 100 matches. After 10,000 matches the search stops counting.
Explore
113 tools. Zero uploads. One place.
Every tool opens instantly, works on your phone and keeps your files on your device.
Regex Tester guides
Related tools
JSON Formatter
Developer Tools
Format, validate and minify JSON instantly.
Open toolBase64 Encode / Decode
Developer Tools
Encode text to Base64 or decode it back.
Open toolURL Encode / Decode
Developer Tools
Percent-encode or decode URLs and query strings.
Open toolUUID Generator
Developer Tools
Generate random UUID (v4) identifiers in bulk.
Open tool