I am new to regeX and I am looking for a expression which satisfy the below condition
- should validate numbers only. decimal is not accepted.(eg :123, 11, 1025,0548)
- should not greater than 7 digits
I tried the below regeX
^[1-9][0-9]*$
but it works fine for numbers which greater than 0.
and then I tried
^[1-9][0-9]\d{1,7}$
but it accept if the digits is greater than 2 numbers. when I give 12
it returns false
. when I give 123
it returns true
and when I give 0124
this will also return false
please refer the below points also for different inputs
- 1, 12, 432, 12414, 1234567 etc all are valid inputs. its greater than 0 and max length is 7
- 01, 0121, 0000001 etc are also valid. 0000001 is greater than 0.
- 0, 12345678 etc are invalid, because it should not accept less than 0 or length greater than 7
- all negative values are invalid, all characters are invalid