regex-dungeon
v0.1.2
Published
A zero-dependency terminal roguelike that teaches regex — slay the monsters that must die, spare the rest, with one regular expression per floor.
Maintainers
Readme
🗡️ regex-dungeon

A zero-dependency terminal roguelike that teaches regex. Each floor throws monsters at you — some you must slay, some you must spare — and you fight them with one regular expression. Match the right ones, miss the wrong ones, descend deeper.
🇰🇷 한국어 설명은 아래에 있습니다.
Floor 3/8 Anchors ^ $ ♥♥♥♡♡
^ = start, $ = end. Without them, a pattern matches substrings too.
▲ SLAY cat
○ SPARE category
○ SPARE scatter
○ SPARE tomcat
your pattern ▶ ^cat$
▲ cat ✓ slain
○ category ✓ spared
○ scatter ✓ spared
○ tomcat ✓ spared
Floor cleared! +110One file, zero dependencies, runs with one command. Auto-detects your language (English / 한국어).
Play
Requires Node.js ≥ 16. No install needed:
npx regex-dungeonOr clone and run:
git clone https://github.com/Haneul-two/regex-dungeon.git
cd regex-dungeon
node index.jsHow it works
- Each floor teaches one regex concept (literals →
./classes → anchors → quantifiers → optionals →\d{n}→ groups/|→ a boss email). - You type a single pattern. The game tests it against every monster:
- ▲ SLAY monsters must match.
- ○ SPARE monsters must not match.
- Get it perfect → floor cleared. Any mistake → lose a heart (♥). Run out → you die.
- Shorter patterns score higher (beat par), fewer attempts score higher.
- Stuck? Type
?for a hint, or??to reveal the answer (that floor scores 0).
regex-dungeon --lang ko # force Korean (or set BEAR_LANG=ko)
regex-dungeon --selftest # verify every floor is solvable
regex-dungeon --helpContributing floors
Floors live in the FLOORS array in index.js. A floor is just data:
{
concept: { en: 'Quantifier +', ko: '수량자 +' },
lesson: { en: '`+` means "one or more"...', ko: '`+` 는 "1개 이상"...' },
slay: ['go', 'goo', 'goooo'], // MUST match
spare: ['g', 'ga', 'good'], // must NOT match
par: 6, // target pattern length
solution:'^go+$' // used by --selftest and the ?? reveal
}PRs with new floors are very welcome — run npm test (it's --selftest) to confirm your floor is solvable by its own solution, then open a PR.
License
MIT
🇰🇷 한국어
의존성 없는 터미널 로그라이크로 정규식을 배우는 게임. 각 층마다 몬스터가 나오는데, 어떤 놈은 반드시 처치하고 어떤 놈은 반드시 살려둬야 합니다. 무기는 정규식 하나. 맞춰야 할 놈만 매치하고 엉뚱한 놈은 피하면서 던전을 내려가세요. 단일 파일, 의존성 0, 명령어 한 줄. 언어는 자동 감지(영어 / 한국어)됩니다.
3/8 층 앵커 ^ $ ♥♥♥♡♡
^ 시작, $ 끝. 없으면 부분 문자열도 매치돼 버립니다.
▲ 처치 cat
○ 회피 category
○ 회피 scatter
○ 회피 tomcat
네 패턴 ▶ ^cat$
...
층 클리어! +110플레이
Node.js ≥ 16 필요. 설치 없이 실행:
npx regex-dungeon규칙
- 각 층은 정규식 개념 1개를 가르칩니다 (리터럴 →
./문자클래스 → 앵커 → 수량자 → 선택 →\d{n}→ 그룹/|→ 보스 이메일). - 패턴 하나를 입력하면 모든 몬스터에 대해 테스트합니다.
- ▲ 처치 몬스터는 반드시 매치돼야 함.
- ○ 회피 몬스터는 절대 매치되면 안 됨.
- 완벽하면 층 클리어. 실수하면 하트(♥) 감소. 다 잃으면 사망.
- 패턴이 짧을수록, 시도가 적을수록 점수가 높습니다.
- 막히면
?로 힌트,??로 정답 공개(해당 층 0점).
regex-dungeon --lang ko # 한국어 강제 (또는 BEAR_LANG=ko)
regex-dungeon --selftest # 모든 층이 풀리는지 검증층 기여하기
층은 index.js 의 FLOORS 배열에 데이터로 들어 있습니다. 새 층 PR을 환영합니다 — npm test(=--selftest)로 본인 층이 solution 으로 풀리는지 확인 후 PR 해주세요.
License
MIT
