Regex Golf Arena

Match the left list, avoid the right list — in as few characters as possible.

Without slashes. Tested with JavaScript RegExp.test (a match anywhere counts unless you anchor with ^ and $). Leave empty to see the puzzle and its leaderboard.

Flags do not count towards the length.

More options

Letters, digits, spaces, dot, dash and underscore; up to 24 characters. Shown publicly with the length and date — the regex itself is never shown.

Try an example: · ·

More about this tool

Part of Proofline Fun & games

How it works

Regex golf with built-in puzzles: write one JavaScript regular expression that matches every string on the “match” list and none on the “don’t match” list. Shorter is better; perfect solutions can join a per-puzzle top-20 leaderboard. Use “dry run” to test without submitting.

  • Your pattern is compiled with JavaScript’s RegExp (flags i/u optional) and tested against every string with RegExp.test, so it may match anywhere in the string unless you anchor it.
  • Score = 10 × (strings on the match list that match + strings on the don’t-match list that do not match) − regex length, as in classic regex golf. A solution is perfect when every string is classified correctly.
  • Safety: patterns are limited to 200 characters, control characters are refused, and patterns where an unbounded quantifier repeats a group that contains another variable quantifier or an alternation — the classic catastrophic-backtracking shapes such as (a+)+ or (a|aa)* — are rejected before running. The puzzle strings are short (at most 12 characters), which bounds the remaining work.
  • Leaderboard: only perfect, non-dry-run solutions are entered, ranked by length, then date. Each puzzle keeps the top 20; an identical regex only counts once, and each nickname keeps its best entry. Only nickname, length, score and date are shown — never the regex — so nobody gets spoilers.

Use this tool in an app

These free programs for your browser have this tool built in, next to everything else the task needs.

  • Proofline Math notebook

    Solve, graph, test and visualise in one notebook — with data, findings and a report.

    Open Proofline

How to use the Regex Golf Arena

Solve regex golf puzzles: write the shortest JavaScript regex that matches one list and avoids the other, test it with a dry run, and join the leaderboard.

What it is for

Regex golf is a puzzle game for people who write regular expressions. You get two lists of short strings. Your pattern must match everything on the left and nothing on the right, using as few characters as possible. It's a fun way to practise back-references, anchors, character classes and lookaheads, and to learn how RegExp.test actually behaves.

The arena has eight built-in puzzles, from a warm-up up to ISO dates, powers of two and a vowel parade. Each puzzle has a par length. Perfect solutions can go on a per-puzzle top-20 leaderboard under a nickname, and only the length and date are shown, never the regex, so nobody gets spoilers.

It is a game, not a regex debugger for your own data. You can't paste your own lists here.

Worked example

Leave the regex empty and pick a puzzle to see the lists. Seeing double (par 5, hint "Back-references remember what they saw") asks you to match balloon, coffee, letter, summer, apple, mirror, bookkeeper, success, hill, jazz and avoid banana, orange, lemon, tomato, potato, grape, melon, mango, kiwi, papaya.

A first attempt listing the doubles you can see, (ll|ff|tt|mm|pp|rr) with dry run on, returned:

/(ll|ff|tt|mm|pp|rr)/ gets 17 of 20 right (score 151): 3 missed, 0 wrongly matched.

The missed strings were bookkeeper, success and jazz, because oo, ss and zz weren't in the list. Rather than adding three more alternatives, use the hint: (.)\1 means "any character, then the same character again".

Perfect! /(.)\1/ (5 characters, score 195) solves "Seeing double" at par. Dry run: perfect, but not submitted.

Score is 10 points per correctly classified string (20 × 10 = 200) minus the length (5), so 195.

How to read the result

  • Summary: perfect or not, length, score, and how you compare with par.
  • Matched / missed: strings from the match list your regex hit or missed.
  • Rejected / false positives: strings from the avoid list you correctly skipped, or wrongly matched.
  • Leaderboard note: whether the attempt was a dry run, not perfect yet, or entered with a rank.

Fix the misses and the false positives first, then shorten. A perfect 20-character regex beats an imperfect 5-character one by a mile.

Tips and common mistakes

  • A match anywhere counts. cat matches educate and vacation. Add ^ and $ only when partial matches cause false positives, because every character costs a point.
  • Flags are free. If a puzzle mixes cases, i can save you from writing [aA].
  • Patterns with nested unbounded quantifiers such as (a+)+ or (a|aa)* are rejected before running, to prevent catastrophic backtracking. Rewrite them without the nesting.
  • Turn on dry run while you experiment. Only perfect, non-dry-run attempts are submitted, and each nickname keeps only its best entry.
  • Look for what the avoid list has in common. In ABBA, aaaa and zzzz are there to stop a lazy (.)(.)\2\1. A negative lookahead fixes that.

FAQ

Which regex flavour is used?

JavaScript's RegExp, tested with RegExp.test. Lookaheads, lookbehinds, back-references and named groups all work. The optional flags are i and u.

Do I type the slashes?

No. Type only the pattern, for example (.)\1, and choose flags from the menu. Flags don't count towards the length.

Can I beat par?

Sometimes. Par is a reference length, not a proven minimum. The leaderboard ranks perfect solutions by length, then by date.

Is my regex shown to others?

No. The leaderboard shows the nickname, length, score and date only. An identical regex submitted twice counts once.

Guide last updated:

For scripts and AI agents

  • JSON API: POST https://regexgolfarena.usefulweb.site/api/v1/calculate (same calculation as this page)
  • Interface description: OpenAPI 3.1 · AI guide: llms.txt
  • MCP server (Streamable HTTP): https://regexgolfarena.usefulweb.site/mcp · tool name regex_golf_arena
Example request
curl -s -X POST https://regexgolfarena.usefulweb.site/api/v1/calculate \
  -H 'content-type: application/json' \
  -d '{"puzzle":"warm-up","regex":"cat","flags":"none","dryRun":true}'
Feedback · ideas & bug reports welcome