Tabwrench tools Small tools that run in your browser. No sign-up, no upload.
Tools / Format / compare / Regex tester

Regex tester

Type a pattern and some text. Matches are highlighted as you type, capture groups are listed in a table, and you can preview a replacement.

Runs in your browser. Nothing you paste leaves this page.
Flags
Test text
Matches

        

The flags

FlagEffect
gFind every match, not just the first.
iIgnore upper and lower case.
m^ and $ match at the start and end of each line.
s. also matches line breaks.
uTreat the pattern as Unicode. Needed for \p{...} classes and for characters outside the basic plane, such as emoji.

Syntax you will use most

PatternMatches
\d   \w   \sA digit, a word character (letter, digit, underscore), whitespace
[abc]   [^abc]   [a-z]One of the listed characters, none of them, a range
a*   a+   a?   a{2,4}Zero or more, one or more, optional, between 2 and 4
a+?   a*?The same, but as few as possible (lazy)
(abc)   (?:abc)   (?<name>abc)Capture group, group without capture, named group
^   $   \bStart, end, word boundary
a(?=b)   a(?!b)a followed by b, a not followed by b (lookahead)

In the replacement field, $1 inserts the first capture group, $& the whole match and $<name> a named group.

Which regex dialect is this?

The page uses your browser's JavaScript engine, so results match what you get in JavaScript and TypeScript code. Most patterns behave the same in Python, Java, Go and PCRE, with a few differences: JavaScript has no possessive quantifiers or atomic groups, and inline flags such as (?i) are not supported in every browser.

Questions

Why does my pattern match too much?

Quantifiers are greedy. ".*" runs from the first quote to the last one on the line. Use ".*?" or "[^"]*".

Why did the page freeze?

Some patterns take exponential time on certain input, for example nested quantifiers like (a+)+$. Reload the tab and simplify the pattern. The same pattern would stall your application too.

Do I need to escape a slash?

Not here. The pattern field holds only the part between the slashes of a JavaScript literal, so / can be typed as is.

Related tools