The string can consist of a single number or multiple numbers separated by "-", but the total character count must not exceed 6.
Examples of valid strings
5
55-33
4444-1
1-4444
666666
Examples of invalid strings
-3
6666-
5555-6666
My initial regex
/^\d+(-?\d+)?$/
However, the original regex considers '5555-6666' as valid even though it exceeds 6 characters in length.
I then attempted the following
/^(\d+(-?\d+)?){1,6}$/
Unfortunately, this interpretation groups all enclosed sets together and expects them to be between 1 and 6 in total.
So, how can we enforce the total character count limit with the described requirements using regex?