-2

I was working on a regex which fulfills below criteria. Kindly suggest.

  1. Must have at least 1 numeric character
  2. Sequential numbers are not allowed
  3. All characters cannot be the same
  4. Minimum of 4 alphanumeric characters allowed
  5. Allow special characters #&()_+[]:;',/.\-" *
  • checkout this http://regexlib.com/Search.aspx?k=password&AspxAutoDetectCookieSupport=1 – Jayant Patil Mar 16 '17 at 06:50
  • checkout this also http://stackoverflow.com/questions/19605150/regex-for-password-must-be-contain-at-least-8-characters-least-1-number-and-bot – Jayant Patil Mar 16 '17 at 06:51
  • @Jayant patil I already tried these but no go – Srishti Kishore Mar 16 '17 at 06:56
  • @SrishtiKishore I cannot see any effort you have done so far. Please, edit your question and add sample code. – Scheff's Cat Mar 16 '17 at 07:20
  • @Scheff I have made below regex which is fulfilling three conditions : 1,4 and 5. Below is the regex: ^(?=(.*[a-z]){1,})(?=(.*[\d]){1,})(?=(.*[\W]){0,})(?!.*\s).{4,}$. m looking for below regex: Sequential numbers are not allowed All characters cannot be the same – Srishti Kishore Mar 16 '17 at 09:55
  • @SrishtiKishore Please, [edit](http://stackoverflow.com/posts/42827017/edit) your question and add the sample code. Please, use the `{}` button in the toolbar of the editor to format it. – Scheff's Cat Mar 16 '17 at 10:59
  • @SrishtiKishore I played with this for a while based on your and @AfzalPatel s efforts. All I got is this pattern for digits I used to match 2. requirement: `(0|(?<!0)1|(?<!1)2|(?<!2)3|(?<!3)4|(?<!4)5|(?<!5)6|(?<!6)7|(?<!7)8|(?<!8)9|9)`. I struggled trying to combine this with the 3. and 4. requirement. – Scheff's Cat Mar 19 '17 at 06:33

1 Answers1

0

I guess you want this:

^(?=.*?[a-zA-Z\d])[\w@#&*+=-]+$

Demo: https://regex101.com/r/qW3oQ8/1

Afzal Patel
  • 124
  • 1
  • 6