Maximal-munch lexical tokens
Lexical Analysis

Answer & solution
Official answer: 13
Givens and goal
Identifiers are letter(letter|digit)*; numbers are digit+; whitespace is ignored. Letters are A-Z or a-z. Tokenize x1 23mm 78 y 7z zz5 14A 8H AaYcD and count non-whitespace tokens.
Approach
At each position take the longest prefix matching a token definition.
Step-by-step solution
1. A letter-starting run can include later digits, so x1, zz5, and AaYcD are each a single identifier. A digit-starting run cannot be an identifier because the initial-letter condition fails.
2. Consequently 23mm splits as number 23 then identifier mm; 7z splits as 7 and z; 14A splits as 14 and A; 8H splits as 8 and H. Whitespace is a separator but is not required at every token boundary.
3. The full sequence is x1 | 23 | mm | 78 | y | 7 | z | zz5 | 14 | A | 8 | H | AaYcD. Numbering these items gives 13 non-whitespace tokens.
4. Equivalently the nine whitespace-separated chunks contribute 1+2+1+1+2+1+2+2+1=13. The answer follows the specified lexer definitions, not any additional rules a particular programming language might impose on malformed numeric literals.
