How to come up with a password of 8 characters. How to write a password in latin letters and numbers: php cyrillic regular expressions. How to come up with a strong password



A regular expression for a password must contain at least eight characters, at least one number and lower and upper case letters and special characters (15)

Use the following Regex to meet the following conditions:

Conditions: 1] Min 1 special character. 2] Min 1 number. 3] Min 8 characters or More

Regex: ^ (? \u003d. * \\ D) (? \u003d. * [# [email protected]!%&*?]){8,}$

Can test online: https://regex101.com

I want a regex to check that:

The password contains at least eight characters, including at least one number, and includes both lowercase and uppercase letters and special characters such as #? ,! ,

It cannot be your old password or contain your username, "password" or "websitename"

And here is my test expression, which is for eight characters, including one uppercase letter, one lowercase letter, and one number or special character.

(? \u003d ^. (8,) $) ((? \u003d. * \\ D) | (? \u003d. * \\ W +)) (?! [. \\ N]) (? \u003d. *) (? \u003d. * ). * $ "

How can I write it for a password, there should be eight characters, including one capital letter, one special character and alphanumeric characters?

@ClasG already suggested:

^ (? \u003d \\ S *) (? \u003d \\ S *) (? \u003d \\ S * \\ d) (? \u003d \\ S * [^ \\ w \\ s]) \\ S (8,) $

but it doesn't accept _ (underscore) as a special character (like Aa12345_).

Improved:

^ (? \u003d \\ S *) (? \u003d \\ S *) (? \u003d \\ S * \\ d) (? \u003d \\ S * ([^ \\ w \\ s] | [_])) \\ S (8,) $

In Java / Android, to validate a password with at least one number, one letter, one special character in the following pattern:

"^ (? \u003d. *) (? \u003d. * \\\\ d) (? \u003d. * [ [email protected]$!%*#?&]){8,}$"

According to your need, this model should work fine. Try this,

^ (? \u003d (. * \\ d) (1)) (. * \\ S) (? \u003d. *) (8,)

Just create a string variable, assign a template and create a boolean method that returns true if the template is correct, false otherwise.

String pattern \u003d "^ (? \u003d (. * \\ D) (1)) (. * \\ S) (? \u003d. *) (8,)"; String password_string \u003d "Type the password here" private boolean isValidPassword (String password_string) (return password_string.matches (Constants.passwordPattern);)

Import JavaScript file jquery.validate.min.js.

You can use this method:

$ .validator.addMethod ("pwcheck", function (value) (return / [\\@\\#\\$\\%\\^\\&\\*\\(\\)\\_\\+\\!\u003e/. //.test(value) && //.test(value) && //.test(value)));

  1. At least one uppercase English letter
  2. At least one lowercase English letter
  3. At least one digit
  4. At least one special character

Hope the below works. I tried this on a custom Azure policy.

(? =. ) (? =. ) (? =. \\ d) (? \u003d. [@ # $% ^ & * -_ + = {} | \: ",? / ~"();!])({}|\\:",?/ ~" (); ] |. (?! @)) {6,16} $

Not directly answering the question, but should it really be a regex?

I've used a lot of Perl and got used to solving regex problems. However, as they get more complex with all the looks and other quirks, you have to write dozens of unit tests to kill all those little bugs.

Also, regex is usually several times slower than imperative or functional solution.

For example, the following (not-so-FP) Scala function solves the original question about three times faster than the regex of the most popular answer. What it does is also so clear that you don't need a unit test:

Def validatePassword (password: String): Boolean \u003d (if (password.length< 8) return false var lower = false var upper = false var numbers = false var special = false password.foreach { c => if (c.isDigit) numbers \u003d true else if (c.isLower) lower \u003d true else if (c.isUpper) upper \u003d true else special \u003d true) lower && upper && numbers && special)

Try this:

^.*(?=.{8,})(?=.*)(?=.*)(?=.*[@#$%^&+=])*$

This regex works great for me.

Function myFunction () (var str \u003d " [email protected]"; var patt \u003d new RegExp (" ^. * (? \u003d. (8,)) (? \u003d. *) (? \u003d. *) (? \u003d. * [@ # $% ^ & + \u003d]) * $ "); var res \u003d patt.test (str); console.log (" Is regular matches: ", res);)

We can just do it using HTML5.

Use below code in template attribute,

Pattern \u003d "(? \u003d ^. (8,) $) ((? \u003d. * \\ D) (? \u003d. * \\ W +)) (?! [. \\ N]) (? \u003d. *) (? \u003d . *). * $ "

It will work great.

Regular expressions do not have an AND operator, so it is quite difficult to write a regex that matches valid passwords when validity is defined by something AND something else AND something else ...

But regular expressions have an OR operator, so just apply DeMorgan's theorem and write a regular expression that matches invalid passwords:

Anything with less than eight characters OR anything without numbers OR nothing but uppercase OR OR nothing, no lowercase letters OR nothing but special characters.

^ (. (0,7) | [^ 0-9] * | [^ A-Z] * | [^ a-z] * | *) $

If anything matches this, then it is the wrong password.

The solution I found in one of the previous answers:

Minimum of 8 characters, at least 1 alphabetical alphabet, 1 lowercase alphabet, 1 number and 1 special character: “^ (? \u003d. ) (? =. ) (? =. \\ D) (? \u003d. [ $ @ $!% ? &]) {8,} "

Doesn't work for me, but the following simplified version and works fine (add any special character you like, I've added # here) and add a number rule just like you did with letters:

"^(?=.*)(?=.*)(?=.*)(?=.*[[email protected]$!%*?&]){8,}"

I would answer to Peter Mortensen, but I don't have enough reputation.

Its expressions are ideal for each of the specified minimum requirements. The problem with his expressions, which don't require special characters, is that they also don't have special characters, and also provide maximum requirements, which I don't believe the OP requested. Usually, you want your users to make their password as strong as they want; Why Limit Strong Passwords?

So, his "at least eight characters, at least one letter and one number":

^ (? \u003d. *) (? \u003d. * \\ d) (8,) $

reaches the minimum requirement, but other characters can be only letter and numbers. To allow (but not require) special characters, you should use something like:

^ (? \u003d. *) (? \u003d. * \\ d). (8,) $ to allow any characters

^ (? \u003d. *) (? \u003d. * \\ d) (8,) $ to allow special special characters

Likewise, “a minimum of eight characters, at least one uppercase letter, one lowercase letter, and one number:

^ (? \u003d. *) (? \u003d. *) (? \u003d. * \\ d) (8,) $

meets this minimum requirement, but allows only letters and numbers. Using:

^ (? \u003d. *) (? \u003d. *) (? \u003d. * \\ d). (8,) $ to allow any characters

^ (? \u003d. *) (? \u003d. *) (? \u003d. * \\ d) (8,) to allow special special characters.

Use 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: /^(?\u003d.*)(?\u003d.*)(?\u003d.*\\d)(?\u003d.*†# [email protected]!%&*?]){8,30}$/

Password generator generates passwords in real time. Created passwords are not saved anywhere and are displayed only on your device (PC, tablet or smartphone).

Each time you change the settings, click the "Generate" button or reload the page, new passwords are generated.

"By default" for generating passwords, English lowercase and uppercase letters, numbers and some service symbols are used. To change the list of symbols use the "Password generator settings"

Password generator settings

Password length
The password generator generates passwords from 5 to 30 characters long. Passwords are initially generated with a length of 10 characters. In general, it is not recommended to use passwords less than 7 characters long. Using longer passwords is recommended for stronger protection against hacking, but will most likely be inconvenient to save or remember.

English and Russian letters
Traditionally, English (Latin) letters are used for passwords, however, Russian can also be used. Russian letters significantly increase the complexity of passwords when trying to crack by brute-force, but be careful, perhaps some systems do not support passwords that include Cyrillic. It is recommended to check beforehand.

Numbers
The numbers in the password must be mandatory. The presence of numbers in the password improves the quality of the password, while passwords with numbers are easier to remember.

Special symbols
Passwords that include special characters that are the most resistant to cracking. When registering, many systems require that the password must include service characters. We recommend that you do not neglect the use of such characters and include them in the generated password.

Exceptions

Russian characters similar to English and English characters similar to Russian
If you use both English and Russian letters when using the online password generator, you may face the problem of visual "similarity" of some English and Russian characters. Letters such as A and A, B and B, C and C, E and E (a, ah, ve, bi, es, si, e, and) are different letters, although they look the same. In order to avoid confusion in the subsequent use of passwords, use the appropriate settings item.

Exclude vowels or exclude consonants
Use these additional settings items if you want to exclude vowels or consonants when generating passwords.

Exclude similar characters
Look at the symbols I, l, 1, | (ay, el, unit, pipe). Such letters, symbols and numbers are very similar in writing, so errors may occur when saving and then using the password. In order to exclude such errors, use this setting item.

Other settings

List of used symbols
The window with the list of used symbols of the password generator contains all those symbols from which passwords are composed, taking into account the current settings. The list can be edited - delete unnecessary and add the symbols you need. When deleting or adding characters in the list editing window, new passwords are automatically generated, taking into account the changes made.

Reset settings
All settings made while using the password generator are automatically saved in the memory (cookies) of your browser. It is the settings that are saved, but not the passwords! As mentioned above, new passwords are generated every time. To reset the settings to their original state, use the "Reset settings" link. When resetting, new passwords are automatically generated based on the original settings.

Link to password generator
If you want to send a link to the "Password Generator" to a friend or post it on social networks, copy the address from the special window located at the bottom of the generator case. Along with the link, the settings you selected are transmitted.

Passwords, passwords, passwords - they are needed everywhere on the Internet. Every time you have to think about which password to put so that it cannot be hacked. So what should be the password?

Signs of a strong password

  • The password must be long, i.e. must be between 8 and 12 characters long.
  • A good password contains uppercase (A, P, V, W) and lowercase (m, d, f, j) letters, symbols (#, @, ~, ^), punctuation marks, and spaces.
  • When creating a password, exclude data containing information about you and your family (names, surnames, memorable dates, phone numbers).
  • Give up a password that includes fully written in any language, catch phrases, famous quotes.
  • Do not use passwords 12345, qwerty and the like. Yes, everyone knows about this, but such passwords are still popular.
  • Avoid passwords that match your login. Of course, such a password is the easiest to type and does not need to be memorized, but it is also easy to crack it.

Try to periodically update and use different passwords across all sites and forums.

How do I come up with a complex password?

There are several effective ways to come up with a strong password:

  • Mixing. We type the Cyrillic word in the Latin register, insert after each letter significant numbers for you (house number, apartment number) or transform some letters into numbers (instead of the letter B we put the number 6, instead of I - 9I, etc.)
  • We type a word or phrase with spaces in the wrong places. For example, "my ypa role".
  • We enter the phrase, alternately pressing the Shift key. For example, BoT-VeDyZ @ SADA
  • We choose two words - an adjective (free) and a verb (run). We add a significant year, for example 1980 and any symbol. We get: Free 19% RUN 80!
  • Coming up with a misspelled password and supplying it with symbols and numbers: KoKoy№ & _Pass.
  • We remember Russian folklore or poetry and encrypt the message. For example, let's take the proverb "Patience and work will grind everything." Let's write every first letter of every word in English in lowercase, and every second in uppercase. We put punctuation marks between the words. We get: tE! I? TR? VS! PT.

Difficult? But the password that you come up with in this way will be reliable.

If you can't come up with a password, use password generators:

How to come up with a login

No registration on the site takes place without using a login. Login is a set of characters (letters or numbers) representing your name on the network. The login is entered together with the password for further authorization. You need to thoroughly approach the selection of a login.

If the login will be used for work, it is advisable to indicate the real name and surname (Petr-Ivanov, Petr_Ivanov, Petr.Ivanov). Is this login already taken? Add a middle name. And this option is not available? Attach the name of the profession to the name, you can shorten it. For example: Alexei-Pirogov-PR, Vasiliy-Toropov-photo.

If you need a login for personal purposes, you can:

  • Come up with a login using your favorite word or phrase, the name of a famous person, character, the name of a musical group.
  • Think about a hobby and come up with a login based on the preferences of the world of art and technology.
  • Create a login from words of any foreign language.
  • Apply the mirrored method and print the name in reverse.
  • Use the login generator.

Collaboration software: choosing the best service!

Task trackers, they are also task managers or collaboration services, are the main digital assistants of modern managers of various levels. AND …

Promotion of services in search engines

Search engine promotion is one of the cheapest channels for attracting customers. But not everyone can order a promotion in an agency ...

Any person who uses the Internet has probably come across the need to come up with and set passwords more than once: to enter the mail, for an account on the forum, for online banking. And in almost every registration form, you are advised to come up with a strong password. After all, the confidentiality of your correspondence, the safety of your money, and the security of your computer as a whole depend on how complex your secret word or phrase will be. The question arises: how do you come up with a complex password?

How to come up with a strong password

Length... The recommended minimum length for a strong password is 8 characters. It is believed that cracking passwords with a length of 8 or more characters by brute force is an overly long process and the chances of an attacker to pick such a combination are too small.

Register... A good password should contain both upper and lower case letters.

Special characters... An extremely secure password, along with letters and numbers, also contains special characters. For example #, ~, +, _

So, the ideal option would be a combination of upper and lower case Latin letters, numbers and special characters with a total length of at least 8 characters. For instance:

uE_xm932
9203Jb # 1
29Rtaq! 2

That in no case can be used as a password

Never use as a password or secret word:

  • date of birth
    The biggest nonsense is to set your own date of birth in the format 12071992 as a password to your Vkontakte page, where the same date is indicated in the information 🙂
  • phone numbers
    A password consisting of your phone number will not be cracked only by the lazy. And it doesn't matter how many digits there are 🙂
  • names, surnames, nicknames of animals
    It's funny when people consider a mother's maiden name to be magically reliable protection. ... which the whole yard has known for 50 years 🙂
  • and of course, all sorts of nonsense like "qwerty123", "password", "password", "********", "123", "12345678", "phywa", "asdf", etc. By the way, the leader among secretaries' passwords is "one", ie one single digit "1" 🙂

Conclusion

Don't neglect your safety.

Keyboard layout and password

Do not use the same secret words for authorization on different sites and services. Hacking one site, attackers can gain access to all your accounts on the network. For example, they will have access to your cloud drive or Google Photos. And remember: nothing is more permanent than temporary. Therefore, do not be lazy to come up with strong combinations and set complex passwords. at once - do not postpone this matter until later. Let your information be available only to you! Good luck!

It might be interesting:

Phonetics of Latin

Latin alphabet

Latin alphabet is the basis for writing many other languages \u200b\u200bfrom different language groups.

Latin alphabet, originating from the Greek alphabet, and according to some sources - the Etruscan alphabet, formedaround the 7th century BC

Modern latin alphabet includes 26 letters.

Latin alphabet letters:

Uppercase
letters
latin
alphabet
Lowercase
letters
latin
alphabet
Name
letters
latin
alphabet
Pronunciation
letters
latin
alphabet
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
and
bae
tse
te
e, e
eff
ge
ha, ha
and
iot, iota
ka
ale
Em
en
about
pe
ku
er
es
te
at
ve
double-ve
X
upsilon
zeta
[and]
[b]
[c]
[d]
[uh]
[f]
[g]
[g]
[and]
[th]
[to]
[l]
[m]
[n]
[about]
[P]
[to]
[R]
[from]
[t]
[y]
[in]
[in]
[ks]
[and]
[h], [dz]

Originally latin alphabet included only 21 letters:
A B C D E F Z H I K L M N O P Q R S T V X.

Then for a sufficient long period latin alphabet underwent the following transformations:
- in 312 BC.

from it was excluded letter Z and the Latin alphabet was reduced to 20 letters;
- in 234 BC e.

How to come up with a strong password and login?

was created letter G by adding a crossbar to C (previously the letter C was used to denote two sounds - [k] and [g]);
- in the 1st century BC e. were added letters Y and Z to write words borrowed from Greek.

As a result, it turned out classic latin alphabet of 23 letters:
A B C D E F G H I K L M N O P Q R S T V X Y Z

In the Middle Ages, the Latin alphabet underwent the last modifications:
- in the 11th century, the alphabet was added letter W;
- in the 16th century there were introduced letters J and U,
and took on its modern form.

However, often speaking about proper Latin alphabet, think that the Latin alphabet consists of 25 letters... This is due to the fact that the letter W, which is used mainly when writing German and English surnames, in this case is not included in the letters of the Latin alphabet.

Go to other materials of the sections:
Phonetics of Latin
Latin grammar
Roman numerals

latin password of 8 characters

Lynn "Coffeeman" [dossier]

Yes, you are absolutely right. Thanks for your expression. I am weak in the regular season, so I did it by the selection method.

AB ... [dossier]
And I would just split the date into three components (split method), and then I did a normal check with checking February and leap year.

The expression was needed to validate the date on input before sending the data. But, let's say, here you are entered "sds20.dfsdf546sdf20.sdf.dfgd.dfgfg02.135151351." I wonder how split would help you here?

Oh, I made a mistake, I forgot in brackets, a thousand apologies (. There may be more bugs - I haven't tested the code, this is a demo of the idea.

tcolonel [dossier], with functionally equivalent regular (February, leap years, etc .;)?

How to create a strong password

tcolonel [dossier] Your regular routine is harmful because it creates an imaginary feeling of security, sooner or later push yourself or the one who will accompany you. If the code does not solve the problem properly, then its effectiveness is highly questionable, as well as the savings on matches at the expense of quality and safety. This is not a professional approach. I hope you don't take this as a personal insult :)

Dear author, take a look at the problem from a different plane and you yourself will understand that you are being told a more correct way to solve the problem instead of where you are going. It reminds me of your actions like putting duct tape on a crack.

message moderated

Accepts the date 11.00.2006

Use the following expression, which, as a bonus, is already testing for a high-yield year. Use it, gentlemen!

Good day to all, help me write a regular expression for a date of the dd.mm.yyyy format.
Made up a simple one:

/(\\d(2)\\.\\d(2)\\.\\d(4))/

but, I can enter 32.32.yyyy. And you need to limit the input for days - 31, months - 12.

I tried this:

/()\\.()\\.(\\d(4))/

but, does not work correctly, from

12.12.2009 01.12.2009 01.02.2009 10.14.2009

finds only 2 matches:

1: 01.12.2009 2: 01.02.2009

Here's what happened in the end:

/(((1)(1))|((1)(1)))\\.((1)(1)|(1)(1)))\\.(\\d(4))/

can someone come up with a better idea and comment on this expression (seems to work correctly)?

Is a meaningless quantifier.
By the way, you have an incorrect expression, you cannot enter the 20th and 10th month.

I would write something like this:

/(\\d|3)\\.(0\\d|1)\\.(\\d(4))/

/(\\d|3)\\.(0\\d\\1)\\.(\\d(4))/ by the way, an interesting expression, I did not know that this is possible ...

tcolonel [dossier] and everything is much simpler than you imagine. there are several solutions. here are a couple for example:

  1. do not allow the user to enter arbitrary data, block the entry into these fields and at the same time use only the calendar in the bundle.
  2. if you give the possibility of free input, then before sending you do elementary checks and if something is wrong, recommend correcting it. in this option and carry out the normal check of the date I already mentioned. how it is done, how to collect the garbage at the same time and what event is used by everyone, perhaps it is not worth explaining in this particular topic.

Something like this?

function dateIsCorrect (dateString) (
var parts \u003d dateString.split (‘.’);
if (parts.length! \u003d 3) return false;
try (
var tmpDate \u003d new Date (parts, parts, parts, 12);
return (dateString \u003d\u003d tmpDate.getDate () + ‘.’ + tmpDate.getMonth + ’.’ + tmpDate.getFullYear ());
) catch (ex) (return false;)
}

If the date is not valid, the Date object will recalculate it to a corresponding normal date, and when converted back to a string, it will not be the same as the original.

AB ... [dossier] Yes, this is all clear, if not to talk about the economy and efficiency of the code, then you can do whole algorithms, just look how many unnecessary actions are against one line of code with a regular expression)))

Ilya Streltsyn aka SelenIT [dossier] Not a bad option too - thanks, but it has a lot of code compared to one line of code with a regex.

Thank you all for your participation.

Ilya Streltsyn aka SelenIT [dossier] with a functionally equivalent regex (February, leap years, etc .;)?

i agree.

Thirteensmay [dossier] Your regular season is harmful because it creates an imaginary feeling of security, sooner or later you will push yourself or the one who will accompany you. If the code does not solve the problem properly, then its effectiveness is highly questionable, as well as the savings on matches at the expense of quality and safety. This is not a professional approach. I hope you don't take this as a personal insult :)

i agree.

AB… [dossier] Dear author, look at the problem from a different plane and you yourself will understand that you are being prompted for a more correct way to solve the problem instead of where you are going. It reminds me of your actions like putting duct tape on a crack.

i agree.

Gentlemen, I agree with everyone. Thank you for your constructive criticism. The choice fell on a regular expression, because what it does exactly for this project is quite enough. And there is no need for such a "hard" check.

P.S: Taking into account all your comments in another project, I have already gone the other way. And did as AB advised ... [dossier] in his first post.

Who wrote this, thank you very much)))

Don't use the expression suggested above

/(\\d|3)\\.(0\\d|1)\\.(\\d(4))/
Accepts the date 11.00.2006

Use the following expression, which, as a bonus, is already testing for a high-yield year.

Use it, gentlemen!

^ (((0 | \\ d | 3) \\. (0 | 1) \\. ((19 | \\ d) \\ d (2))) | ((0 | \\ d | 30) \\. (0 | 1 ) \\. ((19 | \\ d) \\ d (2))) | ((0 | 1 \\ d | 2) \\. 02 \\. ((19 | \\ d) \\ d (2))) | (29 \\ .02 \\. ((1 | \\ d) (0 ||) | ((16 ||) 00)))) $

I need a regex to test this:

The password contains at least eight characters, including at least one number, and includes both lowercase and uppercase letters and special characters such as #,? ,! ...

It cannot be your old password or contain your username, "password" or "websitename"

And here is my validation expression, which is for eight characters, including one uppercase letter, one lowercase letter, and one number or special character.

(? \u003d ^. (8,) $) ((? \u003d. * \\ D) | (? \u003d. * \\ W +)) (?! [. \\ N]) (? \u003d. *) (? \u003d. * ). * $ "

How can I write it for the password should be eight characters long, including one capital letter, one special character, and alphanumeric characters?

javascript asp.net regex

24 Replies


877

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

"^ (? \u003d. *) (? \u003d. * \\ d) (8,) $"

At least eight characters, at least one letter, one number and one special character:

"^ (? \u003d. *) (? \u003d. * \\ d) (? \u003d. * [@ $!% * #? &]) (8,) $"

At least eight characters, at least one uppercase letter, one lowercase letter and one number:

"^ (? \u003d. *) (? \u003d. *) (? \u003d. * \\ d) (8,) $"

At least eight characters, at least one uppercase letter, one lowercase letter, one number and one special character:

"^ (? \u003d. *) (? \u003d. *) (? \u003d. * \\ d) (? \u003d. * [@ $!% *? &]) (8,) $"

Minimum eight and maximum 10 characters, at least one uppercase letter, one lowercase letter, one number and one special character:

"^ (? \u003d. *) (? \u003d. *) (? \u003d. * \\ d) (? \u003d. * [@ $!% *? &]) (8,10) $"


53

Regular expressions do not have an AND operator, so it is quite difficult to write a regex that matches valid passwords when reality is determined by something AND, something else AND, something else ...

But regexes have an OR operator, so just apply DeMorgan's theorem and write a regex that matches invalid passwords:

Anything less than eight characters OR anything that does not contain numbers OR anything that does not contain uppercase letters OR or anything that does not contain lowercase letters OR anything that does not contain special characters.

^ (. (0,7) | [^ 0-9] * | [^ A-Z] * | [^ a-z] * | *) $

If anything matches this, then it is the wrong password.


29

Just a slight improvement for @anubhava's answer: since special characters are limited to those on the keyboard, use this for any special character:

^ (? \u003d. *?) (? \u003d (. *) (1,)) (? \u003d (. * [\\ D]) (1,)) (? \u003d (. * [\\ W]) (1, )) (?!. * \\ s). (8,) $

This regex will apply these rules:

  • At least one uppercase English letter
  • At least one lowercase English letter
  • At least one digit
  • At least one special character
  • At least eight in length


20

I had some difficulty following the most popular answer for my circumstances. For example, my check failed with characters such as; or [ . I was not interested in whitelisting my special characters, so I instead used [^ \\ w \\ s] as a test - more simply - matching non-verbal characters (including numeric ones) and non-spaces. To summarize, here's what worked for me ...

  • at least 8 characters
  • at least 1 numeric character
  • at least 1 lowercase letter
  • at least 1 capital letter
  • at least 1 special character
/^(?\u003d.*?)(?\u003d.*?)(?\u003d.*?)(?\u003d.*? [^\\w\\s\u003e).(8,)$/ ^ (? \u003d \\ S *) (? \u003d \\ S *) (? \u003d \\ S * \\ d) (? \u003d \\ S * [^ \\ w \\ s]) \\ S (8,) $

but it doesn't accept _ (underscore) as a special character (eg. Aa12345_).

Improved one:

^ (? \u003d \\ S *) (? \u003d \\ S *) (? \u003d \\ S * \\ d) (? \u003d \\ S * ([^ \\ w \\ s] | [_])) \\ S (8,) $


2

I found a lot of problems here, so I made my own.

Here it is in all its glory, with trials:

^ (? \u003d. *) (? \u003d. *) (? \u003d. * \\ d) (? \u003d. * ([^ a-zA-Z \\ d \\ s])). (9,) $

There is something to pay attention to:

  1. doesn't use \\ w because that includes _, which I am testing.
  2. I had a lot of problems with matching characters not matching the end of the line.
  3. Doesn't specify symbols specifically, this is also because different locales may have different symbols on their keyboards that they might want to use.


1

We can just do it with HTML5.

Use the below code in the pattern attribute,

Pattern \u003d "(? \u003d ^. (8,) $) ((? \u003d. * \\ D) (? \u003d. * \\ W +)) (?! [. \\ N]) (? \u003d. *) (? \u003d . *). * $ "

It will work perfectly.


1

You can use the below regex pattern to validate the password if it meets your expectations or not.

((? \u003d. * \\\\ d) (? \u003d. *) (? \u003d. *) (? \u003d. * [ [email protected]#$%^&*()]).{8,20})


1

Use the following Regex to meet the following conditions:

Conditions: 1] Min 1 special character. 2] Min 1 number. 3] Min 8 characters or More

Regex: ^ (? \u003d. * \\ D) (? \u003d. * [# [email protected]!%&*?]){8,}$


0

In Java / Android, check a password with at least one number, one letter, one special character as follows:

"^ (? \u003d. *) (? \u003d. * \\\\ d) (? \u003d. * [ [email protected]$!%*#?&]){8,}$"


0

Try this:

^.*(?=.{8,})(?=.*)(?=.*)(?=.*[@#$%^&+=])*$

This regex works perfect for me.

Function myFunction () (var str \u003d " [email protected]"; var patt \u003d new RegExp (" ^. * (? \u003d. (8,)) (? \u003d. *) (? \u003d. *) (? \u003d. * [@ # $% ^ & + \u003d]) * $ "); var res \u003d patt.test (str); console.log (" Is regular matches: ", res);)


0

Hope the below works. I tried this in a custom Azure policy.

^(?=. ) (?=. ) (?=. \\ d) (? \u003d. [@#$%^&*-_+={}|\:",?/ ~"();!])({}|\\:",?/ ~"();!]|.([email protected])){6,16}$


-1

The solution I found in one of the previous answers is like:

At least 8 characters at least 1 uppercase alphabet, 1 lowercase alphabet, 1 number and 1 special character: "^ (? \u003d. ) (?=. ) (?=. \\ d) (? \u003d. [[email protected]$!% ?&]){8 ,}" ..

.

it didn't work for me, but the following simplified version and works fine (add any special character you like, I added # here) and also add a number rule as you do with letters like:

"^(?=.*)(?=.*)(?=.*)(?=.*[[email protected]$!%*?&]){8,}"


Regex password validation using Java conditional statement

I am new to regex. Basically I need to validate a password in Java for the following requirement: Password must be at least six characters long. The password can contain up to 20 characters In order to ...


regex only allow letters, numbers, periods, underscores, dashes. at least 5 characters

How to make regex fit below rules only allow letters (uppercase or lowercase), numbers, periods, underscores, dashes at least 5 characters can not contain common terms or extensions ...


Regex to "disallow special characters or spaces" but "allow numbers and" uppercase "OR" lowercase "letters"

I already use this regex: ^ (6,) $ it allows: numbers, uppercase letters, lowercase letters. it prohibits: spaces and special characters or symbols. But I want to change it to: - allow: ...


Regular expression for password

I need help generating a regex password. The password must contain at least 4 characters, letters (upper and lower case), numbers and special characters - no spaces. MSN as a regular expression.


Regex for a combination of given rules

I am trying to write a regex to check the password for a given rule. Passwords must be at least 8 characters long and contain at least 3 of the following 4 types of characters: lowercase letters (e.g. ...


One regex for complex password verification

I have to check the password to make sure they comply with these rules A) The password must contain characters from 3 of the following 4 classes: English Capital Letters A, B, C, ... Z English Lowercase ...


Regex password must contain at least 8 characters, at least 1 numbers, letters and special characters

I need a regex that must have at least one numeric character, both upper and lower case letters are allowed, special characters are also allowed I am using this ...


Regex for a password of at least 6 characters

I need a regex to validate a password with the below conditions Length at least 6 characters Must contain at least 1 letter Must contain at least 1 number If the password contains special ...


The pattern sometimes matched and sometimes not

I have implemented a template in angular 5 with the following code in a .ts file for password validation. This must be done - support for a minimum of eight characters, at least one uppercase letter, one ...


regex for passwords at least 8 characters long, uppercase, lowercase, numbers, special characters, and non-repeating?

Hi, I want to find a regular expression that satisfies these conditions. (1) passwords must be at least 8 characters long (2) it must contain at least uppercase, lowercase letters, numbers and ...

263 Swapnil tatkondawar

I want a regex to check that:

The password contains at least eight characters, including at least one number, and includes both upper and lower case letters and special characters such as #,? ,! ...

It cannot be your old password or contain your username, "password" or "websitename"

And here is my test expression, which is for eight characters, including one uppercase letter, one lowercase letter, and one number or special character.

(? \u003d ^. (8,) $) ((? \u003d. * \\ D) | (? \u003d. * \\ W +)) (?! [. \\ N]) (? \u003d. *) (? \u003d. * ). * $ "

How can I write it for, the password must be eight characters long, including one capital letter, one special character, and alphanumeric characters?

javascript regex asp.net

24 answers

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

"^ (? \u003d. *) (? \u003d. * \\ d) (8,) $"

At least eight characters, at least one letter, one number and one special character:

"^ (? \u003d. *) (? \u003d. * \\ d) (? \u003d. * [@ $!% * #? &]) $!%*#?&]{8,}$"

At least eight characters, at least one uppercase letter, one lowercase letter and one number:

"^ (? \u003d. *) (? \u003d. *) (? \u003d. * \\ d) (8,) $"

At least eight characters, at least one uppercase letter, one lowercase letter, one number and one special character:

$!%*?&]{8,}$"

Minimum eight and maximum 10 characters, at least one uppercase letter, one lowercase letter, one number and one special character:

"^ (? \u003d. *) (? \u003d. *) (? \u003d. * \\ d) (? \u003d. * [@ $!% *? &]) $!%*?&]{8,10}$"

Regular expressions do not have an AND operator, so it is quite difficult to write a regex that matches valid passwords when reality is determined by something AND something else AND something else ...

But regular expressions have an OR operator, so just apply DeMorgan's theorem and write a regular expression that matches invalid passwords:

Anything less than eight characters OR nothing, no numbers OR, no capital letters OR or nothing but lowercase OR anything that has no special characters.

^ (. (0,7) | [^ 0-9] * | [^ A-Z] * | [^ a-z] * | *) $

If anything matches this, then it is the wrong password.

Just a slight improvement to @anubhava's answer: since the special character is limited to those on the keyboard, use it for any special character:

^ (? \u003d. *?) (? \u003d (. *) (1,)) (? \u003d (. * [\\ D]) (1,)) (? \u003d (. * [\\ W]) (1, )) (?!. * \\ s). (8,) $

This regex will follow these rules:

  • At least one upper letter English letter
  • At least one lowercase English letter
  • At least one digit
  • At least one special character
  • At least eight in length

I had difficulty following the most popular answers to my circumstances. For example, my check did not work with characters such as; or [ . I was not interested in white listings of my special characters, so I instead used [^ \\ w \\ s] as a test - just put - matched characters without words (including numeric ones) and without spaces. To summarize, here's what worked for me ...

  • at least 8 characters
  • at least 1 numeric character
  • at least 1 lowercase letter
  • at least 1 uppercase letter
  • at least 1 special character
/^(?\u003d.*?)(?\u003d.*?)(?\u003d.*?)(?\u003d.*? [^\\w\\s\u003e).(8,)$/

I would answer Peter Mortensen, but I miss the reputation.

Its expressions are ideal for each of the specified minimum requirements. The problem with his expressions, which do not require special characters, is that they also DO NOT ALLOW special characters, so they also enforce the maximum requirement, which I believe is not requested by the OP. Typically, you want your users to make their passwords as strong as they want; Why Limit Strong Passwords?

So, his expression "at least eight characters, at least one letter and one number":

^ (? \u003d. *) (? \u003d. * \\ d) (8,) $

the minimum requirement is reached, but other characters can only be letters and numbers. To allow (but not require) special characters, you should use something like:

^ (? \u003d. *) (? \u003d. * \\ d). (8,) $ to allow any characters

^ (? \u003d \\ S *) (? \u003d \\ S *) (? \u003d \\ S * \\ d) (? \u003d \\ S * [^ \\ w \\ s]) \\ S (8,) $

but it doesn't accept _ (underscore) as a special character (like Aa12345_).

Improved this:

^ (? \u003d \\ S *) (? \u003d \\ S *) (? \u003d \\ S * \\ d) (? \u003d \\ S * ([^ \\ w \\ s] | [_])) \\ S (8,) $

Use the following regular expression to meet the following conditions:

Conditions: 1] Min 1 special character. 2] Min 1 number. 3] Min 8 characters or More
Did you like the article? To share with friends: