R 3

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 3

And here is my validation expression which is for eight characters including one

uppercase letter, one lowercase letter, and one number or special character.

(?=^.{8,}$)((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$"

Minimum eight characters, at least one letter and one number:

"^(?=.*[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:

At least one upper case English letter, (?=.*?[A-Z])


At least one lower case English letter, (?=.*?[a-z])
At least one digit, (?=.*?[0-9])
At least one special character, (?=.*?[#?!@$%^&*-])
Minimum eight in length .{8,} (with the anchors)

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,}$

This regex will enforce these rules:

At least one upper case English letter


At least one lower case English letter
At least one digit
At least one special character
Minimum eight in length

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,}$/

se the following Regex to satisfy the below conditions:

Conditions: 1] Min 1 uppercase letter.


2] Min 1 lowercase letter.
3] Min 1 special character.
4] Min 1 number.
5] Min 8 characters.
6] Max 30 characters.

Regex: /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[#$@!%&*?])[A-Za-z\d#$@!%&*?]{8,30}$/

Try this one:


Minimum six characters
At least one uppercase character
At least one lowercase character
At least one special character
Expression:

"/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[$@$!%*?&.])[A-Za-z\d$@$!%*?&.]{6, 20}/"
Optional Special Characters:

At least one special character


At least one number
Special characters are optional
Minimum six characters and maximum 16 characters
Expression:

"/^(?=.*\d)(?=.*[a-zA-Z]).{6,20}$/"
If the min and max condition is not required then remove .{6, 16}

6 is minimum character limit


20 is maximum character limit
?= means match expression

Re: REGEX password must contain letters a-zA-Z and at least one digit 0-9
Sep 11, 2005 07:09 PM|LINK

This isn't easily done with 1 regex.

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 /* … */

You might also like