users should only be allowed to enter IDs in the format shown below
1
1.1 or 1-1
1.1.1 or 1-1-1
1.1.1.1 or 1-1-1-1
I came up with this regex pattern:
/^(\d+(?:-\d+)*$)|(^\d+(?:\.\d+)*$)/
The current output allows an unlimited number of matches. However, I want to limit it to a maximum of 4 numbers.
1.23.4.55
or 1-23-4-55
are acceptable
but 1.1.1.1.1
, 1-1-1-1-1
, or 21.34.55.5.5.5.5
should be rejected
Despite my efforts, the regex still considers these inputs as valid