Validate the given string which includes the alphanumeric of the length either 6 or 7 (includes space or hyphen only once)
the input string length is either 6 or 7 characters if includes a hyphen or space its length should be 7. Only one space or Hyphen is allowed as a max
Note: the Hyphen or Space is any place in the string and in the below example given few
ex:
A12B3C -> Valid
ACB1234 -> Valid
123H67J -> Valid
ABC-123 -> Valid
ANV 123 -> Valid
ABV-12345 -> Not Valid
ABC 1234 -> Not Valid
ABC-12 -> NOT Valid
ABC 12 -> Not Valid
ABV--35 -> Not Valid
AV- 345 -> Not Valid
AV- 124 -> Not Valid
AV- 124 -> Not Valid
AV-12 5 -> Not Valid
AV-12 5 -> Not Valid
Regex: ^(?![^0-9A-Z]*([0-9A-Z])(?:[^0-9A-Z]*\1)+[^0-9A-Z]*$)(?=.{7}$)[0-9A-Z]+(?:[- ][0-9A-Z]+)?$
failed the cases like ANV123 as its expected 7 characters