regex - Regular Expression to validate my input -
this question has answer here:
- regex allow numbers , 1 hyphen in middle 3 answers
i need regular expression validate input. allowed phrases these:
63 0 3-203 1923-2930 so it's:
- any number, or
- any number - number
you can use following regex
^\d+(-\d+)?$ explanation
^: start with\d+: matches 1 or more numbers()?: matches 0 or 1 group-\d+: matches 1 or more numbers followed -$: ends with
Comments
Post a Comment