regex occurrence of 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 -
You can do this
/^[^-]+-[^-]+$/
^ depicts the start of the string
$ depicts the end of the string
[^-]+ matches 1 to many characters except -