Regex Tester
Test a JavaScript regex live: highlighted matches, capture groups, replace, every flag and a plain-English explanation.
- Free
- No sign-up
- Runs in your browser
See it in action
/(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})/g on "Invoice 2026-11-28, paid on 2026-12-03."
2026-11-28: year 2026, month 11, day 282026-12-03: year 2026, month 12, day 03Replace with $<day>/$<month>/$<year>
Invoice 28/11/2026, paid on 03/12/2026.
3 matches
$& the match · $1, $2 a group · $<name> a named group · $` before · $' after · $$ a dollar sign
| # | Match | Position | Groups |
|---|---|---|---|
| 1 | 2026-11-28 | 8–18 | year: 2026month: 11day: 28 |
| 2 | 2026-12-03 | 28–38 | year: 2026month: 12day: 03 |
| 3 | 2027-01-15 | 53–63 | year: 2027month: 01day: 15 |
What this regex means
(?<year>start of capture group "year" (named)\da digit 0–9{4}repeats the previous item exactly 4 times)end of the group-the character -(?<month>start of capture group "month" (named)\da digit 0–9{2}repeats the previous item exactly 2 times)end of the group-the character -(?<day>start of capture group "day" (named)\da digit 0–9{2}repeats the previous item exactly 2 times)end of the group
Runs in your browser. Nothing you type is uploaded or stored, and no sign-up is needed.
Updated
See it in action
/(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})/g on "Invoice 2026-11-28, paid on 2026-12-03."
2026-11-28: year 2026, month 11, day 282026-12-03: year 2026, month 12, day 03Replace with $<day>/$<month>/$<year>
Invoice 28/11/2026, paid on 03/12/2026.
This regex tester, a regex expression tester and regex pattern tester for JavaScript, runs your regular expression against your text as you type and highlights every match. It lists each match with its position and capture groups (numbered and named), previews a replace with $1, $<name> and the other replacement patterns, and explains the regex token by token in plain English. All eight JavaScript flags (g, i, m, s, u, v, y, d) are one tap away, and a pattern that would hang is stopped after 1.5 seconds instead of freezing the page. It uses your browser's own JavaScript engine, so results are exactly what JavaScript code gets. It is free, needs no sign-up, and your text never leaves your device.
How to use it
Type your regular expression (or paste one like /ab+c/gi) and your test text. Matches are highlighted as you type, with a count.

Switch flags on or off, read each match and its capture groups in the table, and tick Replace with to preview a replacement using $1 or $<name>.

Read What this regex means for a plain-English explanation. If a pattern runs too long it is stopped with an explanation instead of freezing the page. Copy the regex, the matches or the result.

Options
- Regular expression
- Type the pattern, or paste a literal from code such as /ab+c/gi: the slashes are removed and the flags are switched on for you.
- Flags
- g global, i ignoreCase, m multiline, s dotAll, u unicode, v unicodeSets, y sticky and d hasIndices, each with a one-line description. u and v cannot be on together, so turning one on turns the other off.
- Live highlighting
- Every match is highlighted in the text in alternating colors, so matches that sit side by side stay distinct. Empty matches show as a thin bar.
- Matches and groups
- A table of each match with its start and end position and the value of every capture group, by number and by name; a group that did not take part says so. Like a regex evaluator, it shows exactly what the engine returns.
- Replace with
- Preview String.replace with your pattern: $& for the match, $1 to $99 for groups, $<name> for named groups, $` and $' for the text before and after, and $$ for a dollar sign.
- What this regex means
- A regex explainer that reads the pattern token by token in plain English, indented by group: paste any pattern to explain regex syntax you did not write yourself.
- Clear error messages
- A broken pattern gets a plain sentence (for example, a quantifier with nothing before it to repeat) together with the engine's own message.
- Runaway pattern guard
- The regex runs in a background worker; if it takes more than 1.5 seconds it is stopped and the page tells you why.
- Copy
- Copy the regex as a /pattern/flags literal, copy all the matches (one per line), or copy the replaced text.
What a regular expression is
A regular expression (regex) is a pattern that describes text: \d{4} means four digits, [aeiou] means one vowel, colou?r matches both color and colour. Programs use regexes to search, check and replace text.
Each programming language has its own regex flavor. This regex checker uses JavaScript's, which is defined in the ECMAScript standard (ECMA-262, clause 22.2) that browsers and Node.js implement. Because the page runs your pattern with your browser's own engine, the result is exactly what your JavaScript code will get. Use it as an online regex tester for JavaScript, a regex validator before you paste a pattern into code, or a regex debugger when a pattern does not match what you expect.
For regular expression testing you only need the two boxes above: every change runs a JavaScript regex test against your text, so you can test regex patterns and test regular expression online without installing anything. The rest of this page is a reference for when you are writing one.
Source: ECMA-262 (ECMAScript 2025), §22.2 RegExp (Regular Expression) Objects
Regex cheat sheet
| Syntax | Matches |
|---|---|
| . | Any character except a line break (any character with the s flag) |
| \d \D | A digit 0–9 / anything but a digit |
| \w \W | A word character a–z, A–Z, 0–9 or _ / anything else |
| \s \S | Whitespace (space, tab, line breaks, other Unicode spaces) / anything else |
| [abc] [^abc] [a-z] | One of a, b, c / any one character except those / one character in a range |
| ^ $ | Start / end of the text (of each line with the m flag) |
| \b \B | A word boundary / not a word boundary |
| * + ? | Zero or more / one or more / optional |
| {3} {3,} {3,5} | Exactly 3 / 3 or more / 3 to 5 times |
| *? +? {3,5}? | The same, but as few times as possible (lazy) |
| a|b | a or b |
| (…) (?:…) (?<name>…) | Capture group / group that does not capture / named capture group |
| \1 \k<name> | The text a group already matched (backreference) |
| (?=…) (?!…) | Lookahead: followed by / not followed by |
| (?<=…) (?<!…) | Lookbehind: preceded by / not preceded by |
| \p{L} \P{L} | A character with / without a Unicode property such as L (letter); needs u or v |
| \. \* \( \\ | A dot, a star, a bracket, a backslash: escape special characters with \ |
The eight JavaScript regex flags
Any other letter, or the same flag twice, is a syntax error. Without g, a regex finds only the first match, which is the most common reason a regex match seems to miss text: the tester says "first only: add g for all" when that happens.
| Flag | Name | What it does |
|---|---|---|
| g | global | Find every match, not just the first |
| i | ignoreCase | Ignore upper and lower case |
| m | multiline | ^ and $ match at the start and end of every line |
| s | dotAll | . also matches line breaks |
| u | unicode | Unicode mode: \u{…} escapes, \p{…} properties, characters such as emoji count as one |
| v | unicodeSets | Everything u does, plus set operations in classes, such as [\p{L}--[a-z]]; cannot be combined with u |
| y | sticky | Match only at the exact position where the last match ended |
| d | hasIndices | Record the start and end of every capture group |
Regex replace: $1, $<name> and the other patterns
Example: with ^(\w+)\s+(\w+)$ and the flags gm, the replacement $2, $1 turns "Ada Lovelace" into "Lovelace, Ada" on every line. If $10 is used but the regex has fewer than 10 groups, it means $1 followed by a 0, as the standard specifies.
| In the replacement | Inserts |
|---|---|
| $& | The whole match |
| $1 … $99 | Capture group 1 to 99 |
| $<name> | A named capture group |
| $` | The text before the match |
| $' | The text after the match |
| $$ | A dollar sign |
Source: ECMA-262 (ECMAScript 2025), §22.1.3.19.1 GetSubstitution
Groups, lookahead and lookbehind
- A capture group (…) saves what it matched; the tester lists it as 1, 2, 3 in the order the opening brackets appear.
- A named group (?<year>\d{4}) can be read by name: in the table, in a replacement as $<year>, and later in the same regex as \k<year>. The Python form (?P<year>…) is a syntax error in JavaScript.
- A lookahead (?=…) or lookbehind (?<=…) checks the text next to the current position without including it in the match: (?<=\$)\d+ matches 12 in $12. In JavaScript a lookbehind can have any length, so (?<=\$\d+)\.\d+ is valid.
- (?:…) groups without saving, which keeps the numbering of the other groups simple.
When a regex hangs: catastrophic backtracking
Some patterns take time that grows exponentially with the length of the text when the match fails. The classic case is nested repeats such as ^(a+)+$ against a run of a's followed by a character that does not fit: the engine tries every way of splitting the run between the inner and the outer +. A run of n letters can be split in 2^(n−1) ways, so 40 letters give about 5.5 × 10^11 combinations.
This regex tester runs the pattern in a background worker and stops it after 1.5 seconds, so the page never freezes. To fix such a pattern, remove the nesting (^a+$ matches the same text), make the alternatives inside a repeat unable to match the same characters, or anchor and limit the repeat (for example {1,50}).
JavaScript regex vs other flavors
- This regex tool runs JavaScript's engine only; patterns written for another language may behave differently there.
- Inline flags such as (?i) at the start of a pattern are not JavaScript syntax; use the i flag. ECMAScript 2025 adds scoped modifiers such as (?i:…), which work only in browsers that already support them.
- There are no possessive quantifiers (a++) or atomic groups ((?>…)): both are syntax errors here.
- \A and \Z are not anchors in JavaScript: without u or v they simply match the letters A and Z, and with u or v they are errors. Use ^ and $.
- \d matches only the ASCII digits 0–9, even with u. To match digits from other scripts, such as ٣, use \p{Nd} with the u or v flag.
- This is a tester, not a regex generator or regex creator: it checks and explains the patterns you write, but it does not write a pattern for you.
Limits
- Test text up to 200,000 characters.
- The match count stops at 1,000; the table shows the first 100 and Copy matches copies all that were found.
- A pattern that runs longer than 1.5 seconds is stopped.
- Newer regex features (ECMAScript 2025 duplicate group names and modifiers) work only if your browser supports them; the tester reports the browser's own error otherwise.
Questions
How do I test a regex?
Type the regular expression in the top box and your text below it. Every match is highlighted as you type, and the table lists each match with its capture groups.
Is this regex tester online and free?
Yes. It is a free regex tester online, an online regex tool with no sign-up, and it works in any modern browser: check a regex online from a phone or a computer.
Why does my regex match only the first result?
Without the g (global) flag JavaScript stops at the first match. Tap g to find them all.
How do I match a dot, a bracket or a question mark?
Put a backslash before it: \. \( \? and so on. Unescaped, those characters have a special meaning.
How do I make a regex case-insensitive?
Turn on the i flag. JavaScript does not accept (?i) at the start of the pattern.
What is the difference between greedy and lazy?
Greedy repeats (*, +, {n,m}) take as much text as they can; adding ? (*?, +?) makes them take as little as possible. The explanation panel says which one each repeat is.
Can I use this regex tester for Python or PHP?
Simple patterns work the same in most flavors, but this page runs JavaScript's engine, so flavor-specific syntax such as (?P<name>…) or possessive a++ will show an error here.
Is my text uploaded?
No. The regex runs in your browser, in a background worker on your device. Nothing you type is sent anywhere.
More free tools
- Diff CheckerCompare two texts or files side by side, by line, word or character, and export the changes as a .diff.Use it
- JSON Formatter & ValidatorFormat, validate and fix JSON: exact error line and column, beautify or minify, tree view, big numbers kept exact.Use it
- UUID GeneratorGenerate v4, v7 or v1 UUIDs in bulk, as GUIDs, URNs or a JSON array, and check any UUID's version and time.Use it
- Calcul âgeIn FrenchExact age calculator in French: years, months and days between a date of birth and any date.Use it
AI tools for the same job

Replit
FreemiumFrom $18/moTurn ideas into apps in minutes — no coding needed
Coding & Development
JetBrains AI
FreemiumFrom $10/moAI code completion and coding agents across JetBrains IDEs and JetBrains Air
Coding & Development
Amazon Q Developer
FreemiumFrom $19/moGenerative AI-powered assistant for software development
Coding & Development