Mini Tools

Regex Tester for JavaScript

Test JavaScript-compatible regular expressions. Live matches, groups, and error hints. Runs in your browser.

Matches

โ€” use $1, $<name>, $&

Result

    

Match details


    

How to use this regex tester

  • Enter a pattern without slashes, e.g. \b\w+@\w+\.\w+\b, and optional flags such as gi.
  • Paste the text to test against โ€” matches are highlighted as you type.
  • Inspect each match with its index and capture groups (including named groups) in the details panel.

Regex cheat sheet

TokenMatches
.Any character except line breaks (use the s flag to include them)
\d \w \sDigit, word character [A-Za-z0-9_], whitespace
\D \W \SThe opposite of the above
[abc] [^abc] [a-z]Character set, negated set, range
^ $Start / end of input (of each line with m)
\bWord boundary
* + ?0 or more, 1 or more, 0 or 1 (add ? for lazy: *?)
{3} {2,5}Exactly 3, between 2 and 5
(โ€ฆ) (?:โ€ฆ)Capturing group, non-capturing group
(?<name>โ€ฆ)Named capturing group
a|bAlternation โ€” a or b
(?=โ€ฆ) (?!โ€ฆ)Positive / negative lookahead
(?<=โ€ฆ) (?<!โ€ฆ)Positive / negative lookbehind

Flags

gGlobal โ€” find all matches, not just the first
iCase-insensitive
mMultiline โ€” ^ and $ match at line breaks
sDot-all โ€” . also matches newlines
uUnicode โ€” correct handling of code points and \p{โ€ฆ} classes
ySticky โ€” match only at the current position

Useful patterns

Email (simple)^[^\s@]+@[^\s@]+\.[^\s@]+$
Date YYYY-MM-DD^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$
Hex color^#?([0-9a-f]{3}|[0-9a-f]{6})$ with i
IPv4 address^((25[0-5]|2[0-4]\d|1?\d?\d)\.){3}(25[0-5]|2[0-4]\d|1?\d?\d)$
Whitespace at line ends[ \t]+$ with gm

Frequently asked questions

Which regex engine is used?

The JavaScript RegExp engine built into your browser (ECMAScript). Results match what Node.js and browsers do.

How is JavaScript regex different from PCRE (PHP) or Python?

Most syntax is the same. JavaScript has no possessive quantifiers or atomic groups, sets flags after the pattern rather than with (?i) prefixes, and uses (?<name>โ€ฆ) for named groups.

Why does my pattern only find one match?

Without the g (global) flag, only the first match is returned. Add g to find all matches.

How do I match across multiple lines?

Use the m flag so ^ and $ match at each line, and the s flag so . also matches newline characters.

Do I need to escape slashes?

No. Enter the pattern without surrounding /โ€ฆ/ delimiters; slashes inside the pattern do not need escaping here.

Is my text uploaded?

No. All matching happens client-side in your browser.