User can fill in the phone number. (only numbers and dashes, dashes are optional)
It can have as many (medium) dashes ( - ), but the total number of digits should be 10.
I controlled by writing a regular expression using a positive "-" in numbers:
^(?=.*\-)[0-9\-]+$
But I have 2 problems:
ps examples of valid examples:
050-6783828 050-678-38-28 0506783828
not :
-0506783826 0506783826- 050678--3826
ps2 please note that this question is marked as regex. I am not looking for js (non-regex) solutions.
source share