Reputation: 2426
I want validation using regex pattern in my project.
Following are description of regex pattern:
Must be at least 8 characters in length.
Must contain at least 1 UPPER CASE character.
Must contain at least 1 lower case character.
Must contain at least 1 number.
May contain these characters:
" < > $ ~ ' ` ! @ # % ^ & * ( ) - + { } [ ] = : , . ? / | \
Must not use repeating characters. (aa, 11, etc.)
Must not use more than 3 sequential characters. (abcd, wxyz, 1234, etc.)
Upvotes: 3
Views: 227
Reputation: 784998
You can try this regex:
^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9]).{8,}$
PS: It meets all conditions and I didn't include characters mentioned in section e.
since you wrote May contain
and dot will allow all of those.
UPDATE: As per edited question: Use this regex to meet conditions (a) - (f)
^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?:(?!.*?(.)\1).){8,}$
I would highly recomment not using regex for meeting condition (g)
since it will be an awfully long regex.
Upvotes: 10