DevToolsHub Free · Fast · 100% in your browser

Regex Golf

Write the shortest regular expression that matches every word on the left and none on the right. Can you beat par?

Length0
Par5
Your best–
Solved0 / 8

Match all ✔

testCase
testRunner
tested
testify

Match none ✘

contest
attest
retest
latest

About this regex golf game

Regex golf is a puzzle where you write the shortest regular expression that matches every string in one list and none in the other. It is a fun way to practise character classes, anchors, alternation, quantifiers and lookarounds, with your score tracked by pattern length.

How to use the Regex Golf

  1. Read the match and no-match lists.
  2. Type a regex; matches update live.
  3. Shorten the pattern to lower your score.

Example

Match: foo, food, fool · Avoid: bar, baz  →  ^f

Frequently asked questions

Which regex flavour is used?

JavaScript regular expressions, which support lookahead, lookbehind, named groups and Unicode classes.

Does a shorter regex always win?

Yes, as long as it matches all required strings and none of the excluded ones.

Is my data safe?

Yes. The tool runs entirely in your browser using WebAssembly. Nothing you type or upload is sent to a server, logged or stored.

Is it free?

Yes, completely free with no sign-up, no limits and no watermarks. It also works offline once the page has loaded.

An unhandled error has occurred. Reload ✕