I am trying to write a regular expression to allow numbers and only one hypen in the middle (cannot be at the beginning or at the end) for example, pattern: 02-04 , 02 valid, but pattern: -- or - or -02 or 04- or 02-04-06 not acceptable
I tried something like this, but it would allow - at the beginning and also allow a few -
'/^[0-9 \-]+$/'
I am not so familiar with regex, so a little explanation will be really helpful.
EDIT: Sorry to repeat this again, but I need the numbers to be only 2 digits (123-346), considered invalid.
ro ko
source share