In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 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 java regular expressions", the content is simple and clear, and I hope it can help you solve your doubts. Let me lead you to study and learn what java regular expressions have.
Java regular expressions (commonly used) 1. Expressions for check digits 1 digits: ^ [0-9] * $2 n digits: ^\ d {n} $3 at least n digits: ^\ d {n,} $4 mlashi n digits: ^\ d {m N} $5 zero and non-zero digits: ^ (0 | [1-9] [0-9] *) $6 non-zero digits with up to two decimal places: ^ ([1-9] [0-9] *) + (. [0-9] {1 # 2})? $7 positive or negative numbers with 1-2 decimal places: ^ (\ -)?\ d + (\.\ d {1 ~ 2})? $8 positive, negative, negative And decimals: ^ (\-|\ +)?\ d + (\.\ d +)? $9 is a positive real number with two decimal places: ^ [0-9] + (. [0-9] {2})? $10 is a positive real number with 1 / 3 decimal places: ^ [0-9] + (. [0-9] {1cr 3})? $11 is a positive integer that is not zero: ^ [1-9]\ dinteger $or ^ ([1-9] [0-9] *) {1-9} $or ^\ +? [1-9] [0-9] * $12 non-zero negative integers: ^\-[1-9] [] 0-9 "* $or ^-[1-9]\ dnumbers 13 non-negative integers: ^\ dnumbers $or ^ [1-9]\ d* | 0 $14 non-positive integers: ^-[1-9]\ d* | 0$ or ^ (-\ d+) | (0 +) $15 non-negative floating point numbers: ^\ d+ (\.\ d+)? $or ^ [ 1-9]\ d*\.\ d* | 0.\ d* [1-9]\ d* | 0?\ .0 + | 0 $16 non-positive floating point: ^ (-\ d+ (\.\ d+)?) | (0 + (\ .0 +)?) $or ^ (- ([1-9]\ d*\.\ d* | 0.\ d* [1-9]\ d*)) | 0?\ .0 + | 0 $17 positive floating point: ^ [1-9]\ d*. * | 0\.\ d * [1-9]\ dvalve $or ^ (([0-9] +\. [0-9] * [1-9] [0-9] *) | ([0-9] * [1-9] [0-9] +) | ([0-9] * [1-9] [0-9] *) $18 negative floating point number: ^-([1-9]\ d *.\ d * | 0.. \ d * [1-9]\ d *) $or ^ (- (([0-9] +)\. [0-9] * [1-9] [0-9] *) | ([0-9] * [1-9] *. [0-9] +) $19 floating point: ^ (-?\ d +) (\.\ d +)? $or ^? ( [1-9]\ d *.\ d * | 0\.\ d * [1-9]\ d * | 0?\ .0 + | 0) $2. Expression 1 for check characters Kanji: ^ [\ u4e00 -\ u9fa5] {0 } $2 English and numbers: ^ [A-Za-z0-9] + $or ^ [A-Za-z0-9] {4 Magi 40} $3 all characters of length 3-20: ^. {3 Magi 20} $4 string of 26 letters: ^ [A-Za-z] + $5 string of 26 uppercase letters: ^ [Amurz] + $6 string of 26 lowercase letters: ^ [Amurz] + $7 string consisting of numbers and 26 letters: ^ [A-Za-z0-9] + $8 consists of numbers, String consisting of 26 English letters or underscores: ^\ w {3 u9FA5A-Za-z0 20} $9 in Chinese, English, numbers including underscores: ^ [\ u4E00 -\ u9FA5A-Za-z0-9] + $10 Chinese, English, numbers but excluding underscores and other symbols: ^ [\ u4E00 -\ u9FA5A-Za-z0-9] + $or ^ [\ u4E00 -\ u9FA5A-Za-z0-9] {2 int 20} $11 can be entered with ^% &' Characters such as =? $\ ": [^% &' =? $\ x22] + 12 forbids input of characters containing ~: [^ ~\ x22] + 3. Special requirements expression 1 Email address: ^\ w + ([- +.]\ w +) * @\ w + ([-.]\ w +) *.\ w + ([-.]\ w +) * $2 domain name: [a-zA-Z0-9] [- a-zA-Z0-9] {0jue 62} (/. [a-zA-Z0-9] [- a-zA-Z0-9] {0mur 62}) + /.? 3 InternetURL: [a-zA-z] +: / / [^\ s] * or ^ https://([\w-]+\.)+[\w-]+(/[\w-./?%&=]*)?$4 Mobile number: ^ (13 [0-9] | 14 [5 | 7] | 15 [0 | 1 | 2 | 3 | 5 | 6 | 8 | 9] | 18 [0 | 1 | 2 | 3 | 5 | 6 | 7 | 9])\ d {8} $5 phone number ("XXX-XXXXXXX", "XXXX-XXXXXXXX", "XXX-XXXXXXX", "XXX-XXXXXXXX", "XXXXXXX" and "XXXXXXXX): ^ (\ (\ d {3pr 4} -) |\ d {3.4} -)?\ d {7pr 8} $6 domestic telephone number (0511-4405222, 87888822):\ d {3} -\ d {8} |\ d {4} -\ d {7} 7 ID No.: 15 or 18 digit ID: ^\ d {15} |\ d {18} $15 ID: ^ [1-9]\ d {7} ((0\ d) | (1 [0-2]) (([0 | 1 | 2]\ d) | 3 [0-1])\ d {3} $18 Bit ID: ^ [1-9]\ d {5} [1-9]\ d {3} ((0\ d) | (1 [0-2])) (([0 | 1 | 2]\ d) | 3 [0-1])\ d {4} $8 short ID number (number, At the end of the letter x): ^ ([0-9]) {7jue 18} (x | X)? $or ^\ d {8jue 18} | [0-9x] {8jue 18} | [0-9X] {8jue 18}? is the $9 account legal (beginning with the letter) Allow 5-16 bytes, allow alphanumeric underscores): ^ [a-zA-Z] [a-zA-Z0-9 _] {4Gore 15} $10 password (starting with a letter, length between 6x18 and can only contain letters, numbers and underscores): ^ [a-zA-Z]\ w {5cr 17} $11 strong passwords (must contain a combination of uppercase and lowercase letters and numbers, cannot use special characters Length is between 8 and 10): ^ (? =. *\ d) (? =. * [a murz]) (? =. * [Amurz]). {8pm 10} $12 date format: ^\ d {4} -\ d {1J 2} -\ d {1J 2} 12 months of a year (01j 09 and 1x 12): ^ (0? [1-9] | 1 [0-2]) $14 31 days of a month (01Q 09 and 1x 31): ^ ((0? [1-9]) | (1 | 2) [0-9]) | 30 | 31) input format of $15: 161. There are four forms of money that we can accept: "10000.00" and "10000.00", and "10000" and "10000" without "points": ^ [1-9] [0-9] * $17 2. This means any number that does not start with 0, but it also means that a character "0" does not pass, so we take the following form: ^ (0 | [1-9] [0-9] *) $18 3. A 0 or a number that does not start with 0. We can also allow a minus sign at the beginning: ^ (0 | -? [1-9] [0-9] *) $19.4. This represents a 0 or a number that may be negative and begins with a non-zero. Let the user start with 0. Get rid of the negative sign, too, because the money can't be negative. The next thing we want to add is the possible decimal part: ^ [0-9] + (. [0-9] +)? $205. It must be noted that there should be at least 1 digit after the decimal point, so "10." No, but "10" and "10.2" are passed: ^ [0 # 9] + (. [0 # 9] {2})? $21 6. In this way, we stipulate that there must be two digits after the decimal point. If you think it is too harsh, you can go like this: ^ [0-9] + (. [0-9] {1, dint 2})? $22. 7. This allows the user to write only one decimal place. Now it's time to consider the comma in the number. We can go like this: ^ [0-9] {1 # 3} (, [0-9] {3}) * (. [0-9] {1 # # 2})? $238.1 to 3 numbers, followed by any comma + 3 digits, comma becomes optional rather than necessary: ^ ([0-9] + | [0-9] {1 # 3}) [0-9] {3}) *) (. [0-9] {1Magne2})? note $24: this is the end result, don't forget that "+" can be replaced with "*" if you think an empty string is acceptable (strange, why?) Finally, don't forget to remove the backslash when using the function. The general error is here in the 25 xml file: ^ ([a-zA-Z] + -?) + [a-zA-Z0-9] +\. Regular expression of [x | X] [m | M] [l] $26 Chinese characters: [\ u4e00 -\ u9fa5] 27 double-byte characters: [^\ X00 -\ xff] (including Chinese characters) Can be used to calculate the length of a string (a double-byte character length meter 2dASCII character count 1) 28 regular expression of blank lines:\ n\ s *\ r (can be used to delete blank lines) 29 regular expression of HTML tag:] * >. *? | (the version circulated on the Internet is so bad that the above one is only partial There is still nothing you can do about complex nested tags) 30 regular expressions of white space characters at the beginning and end of a line: ^\ s* | or (^\ s*) | (\ sblank $) (which can be used to delete white space characters at the beginning and end of a line (including spaces, tabs, page breaks, etc.) Very useful expression) 31 Tencent QQ number: [1-9] [0-9] {4,} (Tencent QQ number starts from 10000) 32 China Postal Code: [1-9]\ d {5} (?!\ d) (China Postal Code is 6 digits) 33 IP address:\ d +.\ d +\.\ d +\.\ d + (useful when extracting IP addresses) all the contents of the article "what are java regular expressions"? 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.