Regex Tester
Test and debug your JavaScript regular expressions in real-time.
/
/
Matches
0 matchesHow to use the regex tester
- Enter your pattern without slashes, e.g.
\b\d{3}-\d{4}\b. - Enter flags such as
g(find all matches),i(ignore case) orm(multi-line). - Paste your test text. Matches are highlighted live and the match count updates as you type.
The tester uses your browser's JavaScript regex engine, so results match what RegExp does in Node.js and the browser. Other engines (PCRE, Python, Java) differ in some advanced features.
Regex cheat sheet
| Token | Meaning |
|---|---|
. | Any character except a newline |
\d / \w / \s | Digit / word character (letter, digit, underscore) / whitespace |
\D / \W / \S | The opposite of each of the above |
[abc] / [^abc] | One of a, b or c / any character except those |
^ / $ | Start / end of the string (or of a line with the m flag) |
\b | Word boundary |
* / + / ? | 0 or more / 1 or more / 0 or 1 |
{n,m} | Between n and m repetitions |
*?, +? | Lazy (as few as possible) versions |
(…) / (?:…) | Capturing group / non-capturing group |
a|b | a or b |
(?=…) / (?!…) | Lookahead / negative lookahead |
Handy patterns to start from
- Simple email check:
^[^\s@]+@[^\s@]+\.[^\s@]+$ - Indian 10-digit mobile number:
^[6-9]\d{9}$ - Date in YYYY-MM-DD form:
^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$ - Hex colour:
^#([0-9a-fA-F]{3}){1,2}$ - Password with at least one digit, one upper and one lower case letter, 12+ characters:
^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{12,}$
Common mistakes
- Forgetting the
gflag, so only the first match is found. - Not escaping special characters: to match a literal dot, use
\.. - Greedy matching:
<.*>matches from the first<to the last>; use<.*?>. - Catastrophic backtracking: nested quantifiers like
(a+)+can freeze on long input. Keep patterns specific.
Related tools
JSON FormatterFormat, minify and validate JSONBase64 Encoder / DecoderEncode and decode with UTF-8UUID & Token GeneratorUUID v4 and random API tokensQR Code GeneratorQR codes for links, text and Wi-FiRandom Data GeneratorFake names, emails and profilesLorem Ipsum GeneratorPlaceholder text for layouts