Professional Documents
Culture Documents
R 3
R 3
R 3
uppercase letter, one lowercase letter, and one number or special character.
(?=^.{8,}$)((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$"
"^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,}$"
Minimum eight characters, at least one letter, one number and one special
character:
"^(?=.*[A-Za-z])(?=.*\d)(?=.*[$@$!%*#?&])[A-Za-z\d$@$!%*#?&]{8,}$"
Minimum eight characters, at least one uppercase letter, one lowercase letter and
one number:
"^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{8,}$"
Minimum eight characters, at least one uppercase letter, one lowercase letter, one
number and one special character:
"^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[$@$!%*?&])[A-Za-z\d$@$!%*?&]{8,}"
Minimum eight and maximum 10 characters, at least one uppercase letter, one
lowercase letter, one number and one special character:
"^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[$@$!%*?&])[A-Za-z\d$@$!%*?&]{8,10}"
shareimprove this answer
edited Jun 4 at 22:23
Peter Mortensen
11.2k1678110
answered Jan 30 '14 at 12:44
Srinivas
4,259153
9
"^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,}$" does not allow symbols as one of the 8
characters – Wee Jan 6 '15 at 2:30
2
Can you please add sequence of repeated characters to avoid things like 111 or aaa?
– Jonathan Jul 5 '15 at 13:10
5
This will work with non-latin characters: (Minimum 6 characters at least 1
Uppercase Alphabet, 1 Lowercase Alphabet, 1 Number and 1 Special Character:) ^(?
=.*[\p{Ll}])(?=.*[\p{Lu}])(?=.*\d)(?=.*[$@$!%*?&])[\p{Ll}
\p{Lu}\d$@$!%*?&]{6,} –
Kamil Sarna Feb 23 '16 at 17:14
4
@wee This allows optional special chars: ^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d!$%@#£€*?
&]{8,}$ — Minimum 8 characters at least 1 Alphabet and 1 Number with Optional
Special Chars – Philip Bulley Feb 25 '16 at 14:38
1
how can add special characters as optional to my Regex? This is my requirement
"Minimum 8 characters with at least one number , one characters, but special
characters can be optional. – Madhu Mar 16 '16 at 13:16
This regex will enforce these rules:
Just a small improvement for @anubhava's answer: Since special character are
limited to the ones in the keyboard, use this for any special character:
^(?=.*?[A-Z])(?=(.*[a-z]){1,})(?=(.*[\d]){1,})(?=(.*[\W]){1,})(?!.*\s).{8,}$
at least 8 characters
at least 1 numeric character
at least 1 lowercase letter
at least 1 uppercase letter
at least 1 special character
/^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[^\w\s]).{8,}$/
Regex: /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[#$@!%&*?])[A-Za-z\d#$@!%&*?]{8,30}$/
"/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[$@$!%*?&.])[A-Za-z\d$@$!%*?&.]{6, 20}/"
Optional Special Characters:
"/^(?=.*\d)(?=.*[a-zA-Z]).{6,20}$/"
If the min and max condition is not required then remove .{6, 16}
Re: REGEX password must contain letters a-zA-Z and at least one digit 0-9
Sep 11, 2005 07:09 PM|LINK
You need one regex to test for a letter and another to test for a digit.
If you say the password must start with a letter, then the regex is simple: @"^[A-
Za-z]+\d+.*$"
Pattern Description
^\d{5}$ 5 numeric digits, such as a US ZIP code.
^(\d{5})|(\d{5}-\d{4}$ 5 numeric digits, or 5 digits-dash-4 digits. This matches a
US ZIP or US ZIP+4 format.
^(\d{5})(-\d{4})?$ Same as previous, but more efficient. Uses ? to make the -4
digits portion of the pattern optional, rather than requiring two separate patterns
to be compared individually (via alternation).
^[+-]?\d+(\.\d+)?$ Matches any real number with optional sign.
^[+-]?\d*\.?\d*$ Same as above, but also matches empty string.
^(20|21|22|23|[01]\d)[0-5]\d$ Matches any 24-hour time value.
/\*.*\*/ Matches the contents of a C-style comment /* … */