Test, validate and match regular expressions
This regular expression matches the standard format of a Spanish National Identity Document (DNI). It expects exactly 8 digits at the beginning, followed by an optional hyphen separator, and concludes with a single letter. This is commonly used in web forms and applications to validate user input for Spanish identification numbers.