regex to match a single character that has occured only once 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 -