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 > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
In this issue, the editor will bring you some common regular expressions. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.
1. Check password strength
The strength of the password must be a combination of uppercase and lowercase letters and numbers, cannot use special characters, and is between 8 and 10 in length.
^ (? = .*\\ d) (? = .* [amurz]) (? = .* [Amurz]). {8Magol 10} $
two。 Check Chinese
The string can only be in Chinese.
^ [\ u4e00 -\ u9fa5] {0,} $
3. A string consisting of numbers, 26 letters, or underscores
^\\ wish$
4. Verify E-Mail address
As with passwords, the following is a regular check statement for E-mail address compliance.
[\ w]? [\\ w] (?) [: [\\ w] * [\\ w])?
5. Check ID card number
Here is the regular check of the ID card number. 15 or 18.
15:
^ [1-9]\\ d {7} ((0\\ d) | (1 [0-2])) (([0 | 1 | 2]\\ d) | 3 [0-1])\\ d {3} $
18 bits:
^ [1-9]\\ d {5} [1-9]\\ d {3} ((0\\ d) | (1 [0-2])) (([0 | 1 | 2]\\ d) | 3 [0-1]))\\ d {3} ([0-9] | X) $
6. Check date
Date check in "yyyy-mm-dd" format, taking into account flat leap years.
^ (?: (! 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-29) $
7. Check amount
Amount check, accurate to 2 decimal places.
^ [0-9] + (. [0-9] {2})? $
8. Check the mobile phone number
The following is the regular expression of the domestic mobile phone number at the beginning of 13, 15 and 18. (the first two opening digits can be expanded according to the current domestic collection number)
^ (13 [0-9] | 14 [5 | 7] | 15 [0 | 1 | 2 | 3 | 6 | 7 | 8 | 9] | 18 [0 | 1 | 2 | 3 | 5 | 6 | 7 | 9])\\ d {8} $
9. Determine the version of IE
IE has not been completely replaced yet, and many pages still need to be version compatible. Here are the expressions for IE version checking.
^. * MSIE [5-8] (?:\. [0-9] +)? (?!. * Trident\ / [5-9]\ .0). * $
10. Verify IP-v4 address
IP4 regular statement.
\\ 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
11. Verify IP-v6 address
IP6 regular statement.
(([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]))
twelve。 Check the prefix of URL
In application development, it is often necessary to distinguish between HTTPS and HTTP. The following expression can be used to extract a url prefix and then logically judge.
If (! s.match (/ ^ [a-zA-Z] +:\ / /)) {s = 'http://' + s;}
13. Extract URL links
The following expression filters out the URL in a piece of text.
^ (f | ht) {1} (tp | tps):\ /\ / ([\\ w -] +\\.) + [\\ w -] + (\ / [\\ w -. /?% & =] *)?
14. File path and extension check
Verify the file path and extension under windows (.txt file in the following example)
^ ([a-zA-Z]\\: |\)\ ([^\] +\) * [^\ /: *? "|] +\ .txt (l)? $
15. Extract Color Hex Codes
Sometimes you need to extract the color code from a web page, you can use the following expression.
^ # ([A-Fa-f0-9] {6} | [A-Fa-f0-9] {3}) $
16. Extract pictures from web pages
If you want to extract all the picture information from the page, you can use the following expression.
\\
< *[img][^\\\\>] * [src] * = * [\ "\'] {0reco1} ([^\\"\\'\ >] *)
17. Extract page hyperlinks
Extract hyperlinks from html.
(] *) (href= "https?:\ /\ /) ((?! (: (?: (?: www\\.)?'. Implode ('| (?: www\\.), $follow_list).)) [^" rel= "external nofollow"] +) "((?. *\\ brel=) [^ >] *) (?: [^ >] *) >
18. Find the CSS attribute
With the following expression, you can search for a matching CSS attribute.
^\\ s * [a-zA-Z\\ -] +\\ s * [:] {1}\\ s [a-zA-Z0-9\\ s.#] + [;] {1}
19. Extract comments
If you need to remove comments from HMTL, you can use the following expression.
20. Match HTML tags
The tag attributes in HTML can be matched with the following expression.
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.