RegexWars

Codewars, but the only language is regex.

next daily in --:--:--

Tier 4 · EnchantermatchDaily #19

Hex Colours

Match a valid CSS hex colour — a # followed by exactly three or six hex digits, and nothing else.

Three or six, not four or five. A repeated group is the neat way to say that: a group of three, taken once or twice.

Your pattern0 chars · par 24
//
Flags
Start typing — tests run as you go.0 of 7 visible tests passing
Test cases
  • #fffmust match
  • #FFFFFFmust match
  • #a1b2c3must match
  • #ffffmust not match
  • #12345must not match
  • fffmust not match
  • #ggggggmust not match

+ 5 hidden tests, checked when you submit. They are what stops a pattern that only fits the examples above.

Solve it, then shrink it

Passing is the easy half. Your score is the length of your pattern, so the real competition starts once it turns green.

No accounts, no setup

Everything runs in your browser. Nothing to install, nothing to sign up for, and every challenge is free — permanently.

68 challenges, eight tiers

From matching a literal word to writing the regex that detects prime numbers. Browse them all.

RegexWars — Codewars, but the only language is regex