How to use the regex tester
Type a pattern in the top box without the surrounding slashes, and tick the flags you need. Paste the text you want to search into the test string box. Matches are highlighted as you type, in alternating colours so you can tell neighbouring matches apart, and a thin line marks empty (zero-length) matches. The match list below shows each match with its position and every numbered and named capture group. Tick Replace to try a replacement and copy the result. Click one of the common patterns to load a ready-made example, and use Copy link to share your pattern and text with a teammate.
Example: reformat dates
Load the Date (YYYY-MM-DD) pattern. It uses three named groups, year, month and day. In the sample text it finds 2 matches, 2026-10-30 and 2026-11-01, and skips 2026-13-01 because there is no 13th month. The replacement $<day>/$<month>/$<year> turns the first line into Payday is 30/10/2026, holiday on 01/11/2026.
Another everyday case: the PH mobile number pattern matches both 09171234567 and +639281234567, and the number group gives you the 10 digits after the prefix, which is handy for cleaning up contact lists.
Regex cheat sheet
| Syntax | Meaning |
|---|---|
| Character classes | |
. | Any character except a line break (any character with the s flag) |
\d \D | Digit 0–9 / not a digit |
\w \W | Word character [A-Za-z0-9_] / not a word character |
\s \S | Whitespace (space, tab, line break) / not whitespace |
[abc] [^abc] | One of a, b or c / any character except a, b or c |
[a-z0-9] | A range of characters |
\p{L} | Any Unicode letter (needs the u or v flag) |
| Anchors | |
^ $ | Start / end of the text (of each line with the m flag) |
\b \B | Word boundary / not a word boundary |
| Quantifiers | |
* + ? | 0 or more / 1 or more / 0 or 1 |
{3} {2,} {2,5} | Exactly 3 / 2 or more / between 2 and 5 |
*? +? {2,5}? | Lazy versions: match as few as possible |
| Groups and alternation | |
(abc) | Capture group, used as $1 in the replacement or \1 in the pattern |
(?<name>abc) | Named group, used as $<name> or \k<name> |
(?:abc) | Group without capturing |
a|b | a or b |
| Lookarounds | |
x(?=y) x(?!y) | x followed by y / not followed by y |
(?<=y)x (?<!y)x | x preceded by y / not preceded by y |
| Flags | |
g | Global: find all matches, not just the first |
i | Ignore case |
m | Multiline: ^ and $ match at line breaks |
s | Dot-all: . also matches line breaks |
u v | Unicode mode / Unicode sets mode (v adds set operations like [\p{L}--[a-z]]) |
y | Sticky: match only at the current position |
Frequently asked questions
Is my text sent to a server?
No. The pattern, test text and replacement are processed by your own browser in a background worker. Nothing is uploaded, so you can safely test patterns against logs, customer lists or other private data. The share link keeps everything in the part of the URL after #, which browsers never send to the server.
Which regex flavour does this use?
It uses the JavaScript (ECMAScript) engine built into your browser, the same one used by Node.js, Chrome, Edge, Firefox and Safari. Most syntax is shared with PCRE, Python and Java, but a few features differ: for example JavaScript has no possessive quantifiers or atomic groups, and named groups are written (?<name>...).
Why does it say the pattern took too long?
Some patterns, such as (a+)+$, can take exponential time when the text almost matches. This is called catastrophic backtracking. The tester runs each search in a background worker and stops it after 1.5 seconds so the page never freezes. Rewrite the pattern to avoid nested quantifiers on the same characters, for example a+$ instead of (a+)+$.
Why do I only get one match?
Without the g (global) flag, JavaScript stops at the first match, just like String.match and RegExp.exec. Turn on g to find every match. The y (sticky) flag only matches at the current position, so with y the search stops at the first place that does not match.
How do I use capture groups in the replacement?
Use $1, $2 and so on for numbered groups, $<name> for named groups, $& for the whole match, $` and $' for the text before and after the match, and $$ for a literal dollar sign. For example, the pattern (\d{4})-(\d{2})-(\d{2}) with the replacement $3/$2/$1 turns 2026-10-22 into 22/10/2026.