If you just want to check if the input is valid without matching any content, this one should be enough:
^\d{8}-?\d\d$
Beginning with 8 digits, followed (or not) by an optional dash, and another 2 digits up to the end.
0
solved Regex for numbers and a dash [closed]