Home > database >  how to validate 6 digit for pin code in regular expression
how to validate 6 digit for pin code in regular expression

Time:01-16

how to validate 6 digit for pin code in regular expression that should not be serial number like(123456 and 987654) but 3 digit can be serial like (123123) and one digit not includes about 3 times and that should be one or two times like(112233).

I expected the result code.

CodePudding user response:

this is expression for 6 digit pin

/^[0-9]{1,6}$/

you can put this this in your code

for more information :

check this question

CodePudding user response:

Regular expressions are an awful tool for this. Back over at computer science they’ll tell you that every finite language is regular but the regular expression will be absolutely massive.

Just write code. And before you write code ask yourself whether restriction pins is actually a good idea.

The other answer has a regular expression for 1 to 6 digits.

  • Related