Skip to tool
All tools

Regex tester

Live matches, groups and flags for a JavaScript regex.

Questions

What does this tool do?

The Regex tester runs a JavaScript regular expression over your text as you type: every match highlighted, a count, and a table of matches with their positions and groups, numbered and named. A pattern the engine cannot read shows the browser's own message; a pattern that would run forever is stopped after two seconds.

Which regex flavour is this?

JavaScript's — the RegExp your browser runs, so what works here works in your script. Most syntax is shared with PCRE, Python and Go, but not all: lookbehind and named groups are there, possessive quantifiers and atomic groups are not, \d is ASCII digits only, and property escapes like \p{L} need the u flag.

What do the flags do?

g finds every match rather than the first — without it the count stops at one, as in JavaScript. i ignores case. m makes ^ and $ match at line breaks. s lets . match a newline. u turns on Unicode mode, for property escapes and for characters outside the basic plane.

Why does it say the pattern takes too long?

The pattern runs in a separate thread with a two-second limit. Some patterns — nested quantifiers over text that almost matches, like (a+)+$ on a long run of a's — take exponential time; the page stops them and says so instead of freezing.

What does the match table show?

One row per match: what it matched, where it starts and ends, and each group's number, its name when it has one, and what it captured. Positions are character offsets from the start of the text, counted from 0. Past 1,000 matches the table stops and the count carries on.

Related tools