Regular expression that allows 12 numbers and only one hyphen

For example:

123-234523234 - true
-123453634342 - true
12-4-45464325 - false
122342322234- - true 

      

12 rooms and only 1 def. Should appear only once, but anywhere in the quantity field.

+3


source to share


1 answer


What about:



/^(?=\d*-\d*$)[\d-]{13}$/

      

+8


source







All Articles