In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly shows you "what are the common regular expressions for password format verification", which are easy to understand and clear, hoping to help you solve your doubts. Let me lead you to study and learn the article "what are the common regular expressions for password format verification".
Example 1 can only be composed of 1.
Can only be made up of letters, 1-9 digits
^ [a-zA-Z] {1pc9} $
Can only be made up of numbers, 1-9 digits
^\ d {1pc9} $
Can only be made up of special characters, 1-9 bits
^ [^\ da-zA-Z\ s] {1pm 9} $
Contains at least 1 species
Contains at least letters, 1-9 digits
^ (? =. * [a-zA-Z]). {1pm 9} $
At least contain numbers, 1-9 digits
^ (? =. *\ d). {1pr 9} $
Contains at least special characters, 1-9 bits
^ (? =. * [^\ da-zA-Z\ s]). {1pr 9} $
Two kinds can only be composed of two kinds.
Can only be composed of letters and numbers, 1-9 digits
^ (? = .*\ d) (? = .* [Amurz]) [\ da-zA-Z] {1jue 9} $
Can only be composed of letters, special characters, 1-9 digits
^ (? =. * [a-zA-Z]) (? =. * [^\ da-zA-Z\ s]) ([a-zA-Z] | [^\ da-zA-Z\ s]) {1Jet 9} $
Can only be composed of numbers, special characters, 1-9 digits
^ (? =. *\ d) (? =. * [^\ da-zA-Z\ s]) (\ d | [^\ da-zA-Z\ s]) {1LRO 9} $
Contains at least 2 species
Contains at least letters, numbers, 1-9 digits
^ (? = .* [a-zA-Z]) (? = .*\ d). {1pr 9} $
Contains at least letters, special characters, 1-9 digits
^ (? =. * [a-zA-Z]) (? =. * [^\ da-zA-Z\ s]). {1jue 9} $
Contains at least numbers, special characters, 1-9 digits
^ (? = .*\ d) (? = .* [^\ da-zA-Z\ s]). {1jue 9} $
Any two kinds of composition
Consists of letters, numbers, special characters, any two, 1-9 digits
^ (?! [a-zA-Z] + $) (?!\ da-zA-Z $) (?! [^\ DIY\ s] + $). {1JEI 9} $
3 species contain at least 3 species
Contains at least letters, numbers, special characters, 1-9 digits
^ (? = .*\ d) (? = .* [a-zA-Z]) (? = .* [^\ da-zA-Z\ s]). {1jie 9} $
Contains at least letters, numbers, special characters, 1-9 digits, and cannot have 3 consecutive or the same size numbers (e.g.: 456, 654, 888)
^ (? =. *\ d) (?!. * (\ d)\ 1 {2}) (?!. * (012 | 123 | 345 | 456 | 578 | 789 | 987 | 876 | 765 | 543 | 432 | 321 | 210)) (? =. * [a-zA-Z]) (? =. * [^\ da-zA-Z\ s]).
Explain complaints in detail
This piece of content is generally put in the preface, but for the content of the regular expression, it is superfluous to write on it, because the regular expression is rarely used, some people may not be interested in how to write, or want to use it in a hurry, just want to copy and paste after normal operation, my friend belongs to the first two (doctor: the friend you are talking about, is not yourself .jpg).
What you see here should not be in such a hurry, so let's talk about it-what key syntax do you need to know to write regular expressions that meet the criteria for password verification?
The body character describes the position where ^ matches the start of the input string. $matches the end of the input string. * matches the previous subexpression zero or more times. For example, zo* can match "z" and "zoo". * is equivalent to {0,}. + matches the previous subexpression one or more times. For example, "zo+" matches "zo" and "zoo", but not "z". + is equivalent to {1,}. ? Matches the previous subexpression zero or once. For example, "do (es)?" Can match "do" in "does" or "does". ? It is equivalent to {0jue 1}. {ncentine m} matches at least n times and at most m times. For example, "o {1re3}" will match the first three o in "fooooood". "o {0ret 1}" is equivalent to "o?". . Matches any single character except the newline character. [amurz] matches any lowercase letter. [Amurz] matches any uppercase letter. [a-zA-Z] matches any letter and is case-insensitive. \ d matches a number. Equivalent to [0-9]. \ s matches any white space characters, including spaces, tabs, page breaks, and so on. Equivalent to [\ f\ n\ r\ t\ v]. (? = pattern) positive positive pre-check. For example, "Windows (? = 2000)" matches "Windows" in "Windows2000", but not "Windows" in "Windows3.1". (?! pattern) positive negative pre-check. For example, "Windows (?! 2000)" matches "Windows" in "Windows3.1", but not "Windows" in "Windows2000". X | y matches x or y. For example, "z | food" can match "z" or "food". "(z | f) ood" matches "zood" or "food". [xyz] character collection. Matches any of the characters contained. For example, "[abc]" can match "a" in "plain". [^ xyz] negative character collection. Matches any characters that are not included. For example, "[^ abc]" can match "p" in "plain".
The above syntax should be the most common and basic, but not the most critical for writing regular expressions for password format validation.
The key is the following three sets of combined punches:
(? =. * x)
There must be an x.
Ex.: there must be a number-(? =. *\ d), and so on.
(?!. * x)
There can be no x.
Ex.: no numbers-- (?!. *\ d), and so on.
(?! Xerox $)
It can't be all one kind of character.
Ex.: it can't be all numbers-- (?!\ dflowers $), and so on.
With the above formula, it should be easier to understand if you look at the previous example.
Some people here may be a little confused-the table above is not written (? = pattern) to indicate that it matches the previous character before a particular character. Such as:
Windows (? = 2000) matches the word "Windows" in "Windows2000", which is different from the usage mentioned later.
This is because "Windows" in Windows (? = 2000) not only indicates the character to be obtained, but also a filter condition-- when "2000" is preceded by "Windows", that is, Windows (? = Windows2000), changing the regular expression to (? = Windows2000) Windows also matches the "Windows" in "Windows2000". So, when we don't care if there is a "Windows" before "2000", or even if there is a character before it, (? =. * 2000) means there must be "2000" to match the string.
Attached is a simple example of regular expression / * * @ ClassName: RexTest * @ Description: TODO* @ author BMR* @ date 11:09:17 * / public class RexTest {/ * regular expression validation nickname * @ param nickName * @ return * / public static boolean rexCheckNickName (String nickName) {/ / nickname format: limited to 16 characters Support Chinese and English, numbers, minus sign or underscore String regStr = "^ [\\ u4e00 -\\ u9fa5_a-zA-Z0-9 -] {1Magne16} $" Return nickName.matches (regStr);} / * * regular expression validation password * @ param input * @ return * / public static boolean rexCheckPassword (String input) {/ / 6-20 digits, letters, numbers, characters / / String reg = "^ ([Amurz] | [0-9] | [`- = []] ,. / ~! @ # $% ^ * () _ +} {:]) {6pm 20} $"; String regStr =" ^ ([Amurz] | [Amurz] | [0-9] | [`~! @ # $% ^ & * () + = | {}':;',\ [\]. /? ~! @ # ¥%. & * ()-+ | {} []';: "'. ,?]) {6 rexCheckNickName is 20} $"; return input.matches (regStr);} public static void main (String [] args) {System.out.println (" rexCheckPassword is: "+ rexCheckPassword (" 14` ~! @ # $% ^ & * (\) + = | {} ")); System.out.println (" rexCheckNickName is: "+ rexCheckNickName (" Chinese and English-numeric _ minus sign or underscore ")) System.out.println ("rexCheckNickName is:" + rexCheckNickName ("12 texts, numbers, @");}
Output result:
RexCheckPassword is: true
RexCheckNickName is: true
RexCheckNickName is: false
The above is all the contents of the article "what are the common regular expressions for password format verification?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.