Hex colors
A regex exercise from Regexdrill. Solve it with a pattern box with live highlighting in your browser, checked against hidden test strings, and it is checked the moment you submit.
The task
The whole line must match. Match a CSS hex color: # followed by exactly 3 or exactly 6 hex digits (0 to 9, a to f, either case).
What this exercise teaches
#(?:[0-9a-fA-F]{3}){1,2} repeats a block of three hex digits once or twice.
A hint if you get stuck
Three hex digits, once or twice, gives 3 or 6 but never 4 or 5.
This exercise is part of Pro
Pro unlocks all 52 exercises, with worked solutions and progress saved to your account. The free exercises work without an account.
You create a free account first, so Pro is attached to it.
Monthly is charged today and then every month until you cancel, in one click from your account page. Lifetime is one payment with no renewals. Full refund within 14 days of paying.