In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces the regular expressions commonly used in the collection and collation project, which have a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, let the editor take you to understand it.
A recent internal system project involves a lot of text validation, which uses some common regular expressions.
Regular expressions that match Chinese characters: [\ u4e00 -\ u9fa5]
Match double-byte characters (including Chinese characters): [^\ X00 -\ xff] can be used to calculate the length of a string (a double-byte character length meter 2)
Regular expression that matches blank lines:\ n\ s*\ r can be used to delete blank lines
A regular expression that matches the HTML tag:
< (\S*?)[^>] * >. *? |
< .*? />This can only match part of it, and there is nothing you can do about complex nested tags.
Regular expressions that match leading and trailing white space characters: ^\ s * |\ sblank $can be used to delete white space characters (including spaces, tabs, page breaks, etc.) at the beginning and end of a line, which is a very useful expression
Regular expressions that match Email addresses:\ w + ([- +.]\ w +) * @\ w + ([-.]\ w +) *.\ w + ([-.]\ w +) * form validation is very useful
The regular expression that matches the URL URL: [a-zA-z] +: / / [^\ s] * this can basically meet the demand.
Match whether the account is legal (starting with letters, allowing 5-16 bytes, allowing alphanumeric underscores) ^ [a-zA-Z] [a-zA-Z0-9 _] {4j 15} $form validation is very useful
Match domestic phone number:\ d {3} -\ d {8} |\ d {4} -\ d {7} matching form such as 0511-4405222 or 021-87888822
Match Tencent QQ number: [1-9] [0-9] {4,} Tencent QQ number starts from 10000
Match China Postal Code: [1-9]\ d {5} (?!\ d) China Postal Code is 6 digits
Matching ID card:\ d {15} |\ d {18} Chinese ID card is 15 or 18 digits (except for x)
^\ d *\. [0-9]\ matching $/ / matching numbers (including decimals)
^ [1-9]\ positive integer matching $/ /
^-[1-9]\ negative integer matching $/ /
^ -? [1-9]\ match integer
^ [1-9]\ d* | 0 $/ / matches a non-negative integer (positive integer + 0)
^-[1-9]\ d* | 0 $/ / matches non-positive integers (negative integers + 0)
^ [1-9]\ d *\.\ d * | 0\.\ d * [1-9]\ dfloat $/ / matches positive floating point numbers
^-([1-9]\ d *.\ d * | 0.\ d * [1-9]\ d *) $/ / matches negative floating point numbers
^ -? ([1-9]\ d *.\ d * | 0\.\ d * [1-9]\ d * | 0?\ .0 + | 0) $/ / match floating point number
^ [1-9]\ d *.\ d * | 0\.\ d * [1-9]\ d * | 0?\ .0 + | 0 $/ / matches non-negative floating point numbers (positive floating point number + 0)
^ (- ([1-9]\ d *\.\ d * | 0\.\ d * [1-9]\ d *)) | 0?\ .0 + | 0 $/ / matches non-positive floating point numbers (negative floating point + 0)
^ [A-Za-z] + $/ / matches a string of 26 English letters
^ [Amurz] + $/ / matches a string of 26 English letters in uppercase
^ [amurz] + $/ / matches a string of 26 lowercase letters
^ [A-Za-z0-9] + $/ / matches a string of numbers and 26 letters
^\ w match $/ / match a string consisting of numbers, 26 letters, or underscores
The following is actually a code snippet of an enumerated class in the code. I am a little lazy, so I don't want to sort it out in detail:
/ * regular expression of scientific counting * /
REGEX_SCIEN ("^ ((\\ dcounting.?\\ d +) [Ee] {1} (\\ d +)) $", "regular expression of Scientific Counting")
/ * * Mobile number verifies regular expression * /
REGEX_MOBILE ("^ 1 (3 | 5 | 8) [0-9] {9} $", "Mobile number validates regular expression")
/ * regular expression of amount format * /
REGEX_AMOUNT ("^ [-]? [\\ d] {1Magne 10} ([.] {1} [\\ d] {1JEI 2})? $", "regular expression of amount format")
/ * * yyyyMM regular expression * /
REGEX_MONTH ("^ ([1-9]\\ d {3}) (([0] [1-9]) | ([1] [0-2])) $", "yyyyMM regular expression")
/ * yyyyMMdd date format regular expression * /
REGEX_DATE (
"(([0-9] {3} [1-9] | [0-9] {2} [1-9] [0-9] {1} | [0-9] {1-9] [0-9] {2} | [1-9] [0-9] {3}) ((0 [13578] | 1 [02]) (0 [1-9] | [12] [0-9] | 3 [01])) | (0 [469] | 11) (0 [01]) [1-9] | [12] [0-9] | 30)) | (02 (0 [1-9] | [1] [0-9] | 2 [0-8]) | ((0-9] {2}) (0 [48] | [2468] [048] | [13579] [26])) 0229) ")
"yyyyMMdd date format regular expression")
/ * * Email validates regular expressions * /
REGEX_EMAIL (
"^ (([_\\ w -\\] +) @ ((\\ [[0-9] {1rem 3}\. [0-9] {1rem 3}\\.) | (([_\\ w -] +\\.)) ([a-zA-Z] {2pm 4} | [0-9] {1pm 3}) (\\]?) $"
"Email validates regular expressions")
Thank you for reading this article carefully. I hope the article "what are the regular expressions commonly used in collating projects" shared by the editor will be helpful to everyone? at the same time, I also hope that you will support and pay attention to the industry information channel. more related knowledge is waiting for you to learn!
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.