i need to have a regular expression which accept atleast 1 digit number and maximum 5 digit number and if user enter zero in the following fashion like '00','000','0000','00000' then expression should reject such inputs. currently, i am using ^[0-9]{1,5}$.
If you'd make sure that the user's input is formatted as a 5 digit number with leading zeroes, then the following regex would work:
^[0-9]{5}(?<!00000)$
This uses negative lookbehind to ensure that the string entered was not 5 zeroes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With