javascript - Version number validation -
my product version number of format "p.q.r", p, q, r digits. valid inputs "p", "p.q", "p.q.r".
i wrote regular expression performing or operation.
(^\d+$) | (^\d+.\d+$) | (^\d+.\d+.\d$) is there simpler way write using javascript ?
the following regex should work:
^\d+(\.\d+){0,2}$ the \d+ indicates number of digits. (\.\d+) indicates dot followed number of digits, , {0,2} means last group can repeated 0-2 times. ^ , $ indicate start , end of string, regex match whole thing.
Comments
Post a Comment