c# - Regular expression for 0 or a positive number -
i need regular expression check string's value either '0', or positive number length equal 1 10 (also first digit cannot zero).
i'm stuck, can 0, can't positive number.
here have:
(^([0])$)|(^([1-9][0-9]{0-9})$)
this reg exp looks little crazy, i've been trying lot of different things , making more crazier , crazier.
for range of possibilities, use comma, not hyphen.
(^([0])$)|(^([1-9][0-9]{0,9})$)
however, regex can shortened to:
^(0|[1-9][0-9]{0,9})$
Comments
Post a Comment