REGEX password validation

Asked

Viewed 610 times

4

I have a Validation problem and I cannot apply within a simple structure, 3 validations cannot have decreasing, increasing or repeated alphanumerics in the same password.

For example: 00000000 , 01234567 , 98765432 , Aaaaaaaa, aa1123456

someone can help me ?

  • 10

    If I were your user, I would appreciate it if you didn’t restrict the password (even more so at this level). Good luck.

  • How many repeated characters will be considered to say that the password has to be in this validation, for example the password aa123r56, would be valid? your password will always be composed by 8 characters?

  • the password aa123r56 would not be valid because there is a repeat sequence in aa and 123 in the same password at first yes would be 8 characters possibly will increase the value of the field. I used a previous solution but, it did not suit me well, because of the documentation.

  • It seems that detecting sequences using regex is not possible. See this topic in Soen, it may help. http://stackoverflow.com/questions/8880088/regular-expression-to-match-3-or-more-consecutive-sequential-characters-and-cons

  • As far as I know, it is not possible to detect sequence of numbers with regex. It is possible to detect repeated numbers or letters, such as 000 or aaa, but a sequence 123, 987 or abc nay.

  • 1

    You mean if my birth year was 1987 I couldn’t use it because it was sequential?

Show 1 more comment

1 answer

1

As far as I know, it is not feasible to detect sequence of numbers with regex.
It is possible to detect repeated characters easily, such as 000 or aaa, but a sequence 123, 987 or abc not.

The regex by itself, does not assign value to characters. It nay identifies that 2 is greater than 1 or that b is followed by a in the alphabet. To do this you would have to write all possible sequences for it to give match in any of them. As an example to Pattern "123|12|23|321|32|21" to identify a single sequence between three numbers.

For repeated letters or numbers you could use a Pattern searching for repeated occurrences such as "(\d|\w)\1+".
In that case the Pattern gets a letter or number and then checks if it repeats once or more. See working on regex101.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.