In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you what java regular expressions are commonly used, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
1. Numeric validation expression
Demand expression number ^ [0-9] * the number of $n bit ^\ d {n} $mmurn bit ^\ d {m N} $zero and non-zero beginning numbers ^ (^ ([1-9] [0-9] *) + (. [0-9] {1m 2})? $positive or negative numbers with 1-2 decimal places ^ (\ -)?\ d + (\.\ d {1pc2})? $positive, negative, And decimal ^ (\-|\ +)?\ d+ (\.\ d+)? $positive real number ^ [0-9] + (. [0-9] {2}) with two decimal places? $positive real number ^ [0-9] + (. [0-9] {1 ^ 3})? $non-zero positive integer ^ [1-9]\ dcounting $or ^ ([1-9] [0-9] *) {1pm 3} $or ^\ +? [1-9] [0-9] * $non-zero negative integer ^\-[1-9] [] 0-9 "* $or ^-[1-9]\ dcircle $non-negative integer ^\ DX $or ^ [1-9]\ d* | 0$ non-positive integer ^-[1-9]\ d* | 0$ or ^ (-\ d+) | (0 +) $non-negative floating point number ^\ d+ (\.\ d+)? $or ^ [1-9]\ d*\ .\ d* | 0\.\ d* [1-9]\ d* | 0?\ .0 + | 0$ non-positive floating point ^ ((-\ d+ (\.\ d+)?) | (0 + (\ .0 +)?)) $or ^ (([1-9]\ d*\.\ d* | 0.\ d* [1-9]\ d*)) | 0?\ .0 + | 0$ positive floating point ^ [1-9]\ d*.\ d* | 0.\ d* [1-9]. 9] [0-9] $or ^ (([0-9] +. [0-9] * [1-9] [0-9] *) | ([0-9] * [1-9] [0-9] +) | ([0-9] * [1-9] [0-9] *)) $negative floating point ^-([1-9]\ d*\.\ d* | 0.\ d* [1-9]\ d* ) $or ^ (- ([0-9] +\. [0-9] * [1-9] [0-9] *) | ([0-9] * [1-9] [0-9] *) | ([0-9] * [1-9] [0-9] *) $floating point number ^ (-?\ d +) (\.\ d +)? $or ^ -? ([1-9]\ d *\.\ d * | 0\.\ d * [1-9]\ d* | 0?\ .0 + | 0) at least n bits ^\ d {n } $
2. Character validation expression
Demand expression Chinese character ^ [\ u4e00 -\ u9fa5] {0 } $English and numbers ^ [A-Za-z0-9] + $or ^ [A-Za-z0-9] {4pm 40} $all characters 3-20 in length ^. {3pm 20} $string of 26 letters ^ [A-Za-z] + $string of 26 uppercase letters ^ [Amurz] + $string of 26 lowercase letters ^ [A-Za-z] + $consisting of numbers and The 26-letter string ^ [A-Za-z0-9] + $consists of numbers, A string consisting of 26 English letters or underscores ^\ w {3 u9FA5A-Za-z0 20} $Chinese, English, numbers including underscores ^ [\ u4E00 -\ u9FA5A-Za-z0-9] + $, English, numbers but excluding symbols such as underscores ^ [\ u4E00 -\ u9FA5A-Za-z0-9] + $or ^ [\ u4E00 -\ u9FA5A-Za-z0-9] {2} 20} $can be entered with ^% &' Characters such as =? $\ "[^% &',; =? $\ x22] + prohibit the input of characters containing ~ [^ ~\ x22] +. * match any Chinese characters except\ n / [\ u4E00 -\ u9FA5] /
3. Special requirements expression
Requirement expression Email address ^\ w+ ([- +.]\ w+) * @\ w+ ([-.]\ w+) *\.\ w+ ([-.]\ w+) * $domain name [a-zA-Z0-9] [- a-zA-Z0-9] {0a-zA-Z0 62} (/. [a-zA-Z0-9] [- a-zA-Z0-9] {0jue 62}) + /.? InternetURL [a-zA-z] +: / / [^\ s] * Or ^ http://([\w-]+\.)+[\w-]+(/[\w-./?%&=]*)?$ Mobile phone number ^ (13 [0-9] | 14 [5 | 7] | 15 [0 | 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9] | 18 [0 | 1 | 2 | 5 | 6 | 7 | 8 | 9])\ d {8} $phone number ("XXX-XXXXXXX", "XXXX-XXXXXXXX", "XXX-XXXXXXX", "XXX-XXXXXXXX", "XXXXXXX" and "XXXXXXXX) ^ (\ (\ d {3, 4} -) |\ d {3. 4} -)?\ d {7} $domestic telephone number (0511-4405222, 021-87888822)\ d {3} -\ d {8} |\ d {4} -\ d {7} ID card number (15 digits, 18 digits) ^\ d {15} |\ d {18} $short ID card number (number, number, 18 digits) End of letter x) ^ ([0-9]) {7Magne18} (x | X)? $or ^\ d {8pr 18} | [0-9x] {8pr 18} | [0-9X] {8p 18}? is the account legal (beginning with the letter)? Allow 5-16 bytes, alphanumeric underscore) ^ [a-zA-Z] [a-zA-Z0-9 _] {4jue 15} $
Password (starts with a letter, is between 6 and 18 in length and can only contain letters, numbers and underscores) ^ [a-zA-Z]\ w {5pc17} $strong password (must contain a combination of uppercase and lowercase letters and numbers, no special characters can be used The length is between 8 and 10) ^ (? =. *\ d) (? =. * [Amurz]) (? =. * [Amurz]). {8pm 10} $date format ^\ d {4} -\ d {1J 2} -\ d {1J 2} 12 months of a year (01x 09 and 1x 12) ^ (0? [1-9] | 1 [0-2]) 31 days of a month (01pm 09 and 1x 31) ^ (0? [ 1-9]) | (1 | 2) [0-9]) | 30 | 31) expressions of $"10000.00" and "10000.00" And expressions of "10000" and "10000" ^ [1-9] [0-9] * $without "points" Any number that does not start with 0, however, this also means that a character "0" does not pass the expression of ^ (0 | [1-9] [0-9] *) $, a 0 or a number that does not start with 0. We can also allow a negative sign ^ (0 | -? [1-9] [0-9] *) $0 or a number that may be negative and begins with a non-zero. Let the user start with 0. Remove the minus sign, too. What we want to add next is the possible decimal part ^ [0-9] + (. [0-9] +)? $it must be stated that there should be at least 1 digit after the decimal point, so "10." No, but "10" and "10.2" are passed by ^ [0-9] + (. [0-9] {2})? there must be two places ^ [0-9] + (. [0-9] {1)) after the $decimal point? $allows the user to write only one decimal place. Comma ^ [0-9] {1pc3} (, [0-9] {3}) * (. [0-9] {1pc2})? $1 to 3 digits, followed by any comma + 3 digits, comma becomes optional rather than necessary ^ ([0-9] + | [0-9] {1 + 3}) [0-9] {3}) *) (. [0-9] {1 u9fa5 2})? $xml file ^ ([a-zA-Z] + -?) + [a-zA-Z0-9] +\. [X | X] [m | M] [l | L] $Chinese characters [\ u4e00 -\ u9fa5] double-byte characters [^\ x00 -\ xff] (including Chinese characters) Can be used to calculate the length of a string (a double-byte character length meter)) blank lines\ n\ s *\ r (can be used to delete blank lines) HTML tag] * >. *? | (incomplete Need to find separately) the leading and trailing blank characters ^\ s* |\ sblank $or (^\ s*) | (\ sblank $) (can be used to delete white space characters at the beginning and end of a line (including spaces, tabs, page feeds, etc.) Very useful expression) Tencent QQ number [1-9] [0-9] {4 } (Tencent QQ number starts from 10000) China Postal Code [1-9]\ d {5} (?!\ d) (China Postal Code is 6 digits) IP address\ d +\.\ d + (useful when extracting IP address) IP address ((?): (?) 25 [0-5] | 2 [0-4]\ d | [01]?\ d?\ d)\\.) {3} ( ?: 25 [0-5] | 2 [0-4]\ d | [01]?\\ d?\\ d) IP-v4 address\\ b (?: 25 [0-5] | 2 [0-4] [0-9] | [01]? [0-9] [0-9]?)\\.) {3} (?: 25 [0-5] | 2 [0-4] [0-9] | [01]? [0-9] [0-9]) ?)\\ b (useful when extracting IP addresses) verify IP-v6 addresses
(([0-9a-fA-F] {1rect 4}:) {79a-fA-F 7} [0-9a-fA-F] {1pr 4} | ([0-9a-fA-F] {1pr 4}:) {1Mague 7}: | ([0-9a-fA-F] {1pr 4}:) {1pr 6}: [0-9a-fA-F] {1pr 4} | ([0-9a-fA-F] {1pm 4}:) {1pm 5} (: [0-9a-fA-F] {1pm 4}) {1pm 2}) | | ([0-9a-fA-F] {1score4}:) {19a-fA-F 4} (: [0-9a-fA-F] {1score4}) {19a-fA-F 3} | ([0-9a-fA-F] {1Power4}:) {19a-fA-F 3} (: [0-9a-fA-F] {1pr 4}) {1c4} | ([0-9a-fA-F] {1pr 4}:) {1pr 2} (: [0-9a-fA-F] {1pm 4}) {1pm 5} | ] {19a-fA-F 4}: (: [0-9a-fA-F] {1 9a-fA-F 4}) {1 9a-zA-Z 6}) | (: (: [0-9a-fA-F] {1 9a-zA-Z 4}) {1 9a-fA-F 7} |:) | (: [0-9a-fA-F] {0pr 4}) {0pr 4}% [0 -] {1 | |:: (ffff (: 0 {0 9a-fA-F 4}) {0Power1}:) {0ffff 1} ((25 [0-5]) | (2 [0-4] | 1 {0Power1} [0-9]) {0Magne1} [0-9]) {0Magne1} (25 [0-5] | (2 [0-4] | 1 {0quotient 1} [0-9]) {0jin1} [0-9]) | ([0-0] 1}:) {1pm 4}: (25) [0-5] | (2 [0-4] | 1 {0rect 1} [0-9]) {0rect 1} [0-9])\\.) {3jue 3} (25 [0-5] | (2 [0-4] | 1 {0jue 1} [0-9]))
Subnet mask ((?: 25 [0-5] | 2 [0-4]\ d | [01]?\\ d?\\ d)\\.) {3} (?: 25 [0-5] | 2 [0-4]\ d | [01]?\ d?\\ d)) check date
^ (?: (! 0000) [0-9] {4}-(: 0 [1-9] | 1 [0-2])-(?: 0 [1-9] | 1 [0-9] | 2 [0-8]) | (?: 0 [13-9] | 1 [0-2])-(?: 29 | 30) | (?: 0 [13578] | 1 [02])-31) | (?: [0-9] {2} (?: 0 [48]) | 2468] [048] | [13579] [26]) | (?: 0 [48] | [2468] [048] | [13579] [26]) 00)-02-
Format date check, has considered flat leap year $(date check in "yyyy-mm-dd" format, has considered flat leap year.) Extract comments to find CSS attributes ^\\ s * [a-zA-Z\\ -] +\\ s * [:] {1}\\ s [a-zA-Z0-9\\ s.#] + [;] {1} extract page hyperlinks
(] *) (href= "https?:\ /\ /) ((?! (: (?: (?: www\\.)?'. Implode ('| (?: www\\.), $follow_list).)) [^" rel= "external nofollow"] +) "((?. *\\ brel=) [^ >] *) (?: [^ >] *) >
Extract web page images\\
< *[img][^\\\\>] * [src] * = * [\ "\] {0Magne1} ([^\"\] *) extract the web page color code ^ # ([A-Fa-f0-9] {6} | [A-Fa-f0-9] {3}) $file extension validation ^ ([a-zA-Z]\: |\)\\ ([^\] +\) * [^\\] \ /: *? "|] +\ .txt (l)? $judge the IE version ^. * MSIE [5-8] (?:\. [0-9] +)? (?!. * Trident\ / [5-9]\ .0). * $full-width symbol / [\ uFF00-\ uFFFF] / half-width symbol / [\ u0000 -\ u00FF] / above is all the content 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.