Regular Expressions & Languages


Answer & solution
Answer: L(ε|A|A²|A³|A⁴|A⁵), A=L∪D. (no official key was published)
Let L denote the finite union of permitted letters and D the union of decimal digits. Let A=L|D. The first character must be from L. It can be followed by zero through five alphanumeric characters, giving
L(ε | A | AA | AAA | AAAA | AAAAA).
With repetition shorthand this is L A{0,5}. The expanded expression above uses only ordinary regular-expression union, concatenation and ε; braces are not essential notation.
A one-letter identifier follows the ε branch; a six-character one follows AAAAA. No branch accepts an empty identifier or a first digit, and none permits a seventh character. Conversely any permitted identifier can be decomposed into its initial letter and its remaining zero to five alphanumeric symbols, so it is accepted. The actual letter alphabet, such as upper/lowercase distinctions, is a language-design input; underscores are not included because the question permits only letters and digits.