Regex Golf Arena
Match the left list, avoid the right list — in as few characters as possible.
Try an example: Warm-up, dry run · Seeing double, almost right · Show the ABBA puzzle
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.
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 nameregex_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}'