regex match single occurrence of a character code example
Example: regex only one occurrence of character
You can do this
/^[^-]+-[^-]+$/
^ depicts the start of the string
$ depicts the end of the string
[^-]+ matches 1 to many characters except -