SKU codes
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. A SKU is three capital letters, a hyphen and four digits, optionally followed by a hyphen and a size: XS, S, M, L or XL.
What this exercise teaches
[A-Z]{3}-\d{4}(?:-(?:XS|S|M|L|XL))? allows only the five listed sizes.
A hint if you get stuck
List the sizes as alternatives inside an optional group that starts with the hyphen.
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.