AL HARPER
AL HARPER

Reputation: 21

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

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

Upvotes: 2

Views: 855

Answers (1)

700 Software
700 Software

Reputation: 87783

What flavor/language?

Here is the initial answer before having more information.

(?!0{4})\d{4}

Upvotes: 9

Related Questions