Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Testing for at least 1 non 0(zero) digit out of 4

Tags:

regex

I need a regex test that will test a field of 4 digits making sure at least one of the 4 digits is non-zero. Example:

abcd0000efgh - fail
abcd0001efgh - pass
abcd0010efgh - pass
abcd0100efgh - pass
abcd1000efgh - pass
abcd1234efgh - pass
abcd4321efgh - pass

Thanks

like image 948
AL HARPER Avatar asked Jan 16 '26 23:01

AL HARPER


1 Answers

What flavor/language?

Here is the initial answer before having more information.

(?!0{4})\d{4}
like image 125
700 Software Avatar answered Jan 19 '26 18:01

700 Software



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!