Regex tester · JavaScript flavour

Test, explain and share regular expressions

Matches and capture groups light up as you type. Preview replacements and splits, read every token in plain English, and copy working code for five languages.

Flags

5 matches

135 characters

How the tester works

Type a pattern between the slashes and the test string on the left lights up: each match gets a vermilion or ochre wash, and every capture group is underlined in its own colour, the same colour its parentheses have in the pattern and its entry in the match table. Hover a row in the table to find that match in the text; click it to select it.

Matching runs in a Web Worker using your browser’s own JavaScript engine, so results are exactly what RegExp gives in your code. If a pattern backtracks catastrophically, the worker is stopped after one second instead of freezing the page.

Share copies a link that holds the pattern, flags and test text in the part of the address after #. Browsers never send that part to a server, and RegexQuill removes it from the address bar once the page has read it.

The flags

  • g finds every match; without it only the first one counts.
  • i ignores case; m lets ^ and $ match at line breaks.
  • s lets . match line breaks too.
  • u turns on Unicode mode (needed for \p{…}); v adds set operations and emoji sequences.
  • y only matches at lastIndex; d records group positions.

More regex tools

Questions

Which regex flavour does RegexQuill test?

JavaScript (ECMAScript), using the engine of the browser you are on. That includes lookbehind, named groups, Unicode property escapes, the v flag and, in current browsers, pattern modifiers. The Code tab translates the pattern for Python, PHP, Go and Java and lists the differences that matter.

Is my pattern or test text uploaded anywhere?

No. Parsing, matching and code generation all happen in your browser. A share link carries the pattern and text after the # in the address, a part that browsers never send to servers.

Why did the tester stop with “took too long”?

The pattern is probably backtracking catastrophically on this text: nested or overlapping quantifiers make the engine try an enormous number of ways to match. Matching runs in a worker that is stopped after one second. Open the pattern in the ReDoS checker to see which part causes it.

What do the colours mean?

Matches alternate between a vermilion and an ochre wash so neighbouring matches stay distinct. Each capture group has its own colour, used for its parentheses in the pattern, its underline in the text, its column in the table and its part of the split preview.

Why does my regex match here but not in my code?

Check the flags first: without g only the first match counts, and without m the anchors ^ and $ only match at the very start and end. In a string passed to new RegExp(), every backslash must be doubled; the Code tab writes that for you.