20 regular expressions are often used in front-end development.

1. Verify password strength: the strength of password must include the combination of upper and lower case letters and numbers. Special characters cannot be used, and the length is between 8 and 10


2. Check Chinese: the string can only be Chinese


3. A string of numbers, 26 English letters or underscores


4. Verify E-Mail address


5. Verify ID number
15 place


18 place


6. Verification date: "yyyy MM DD" format of date verification, which has considered flat leap year.


7. Verification amount: accurate to two digits


8. Verify mobile number: the following is the domestic mobile number regular expression starting with 13, 15 and 18. (the first two numbers can be extended according to the current domestic collection number)


9. Judge that the IE version has not been completely replaced. Many pages still need to be version compatible. The following is the expression of IE version check.

^.*MSIE [5-8](?:\\.[0-9]+)?(?!.*Trident\\/[5-9]\\.0).*$

10. Verify IP-V4 address: IP4 regular statement


11. Verify IP-V6 address: IP6 regular statement


12. check the prefix of URL: in application development, it is often necessary to distinguish whether the request is HTTPS or HTTP. Through the following expression, a prefix of URL can be taken out and then judged logically

if (!s.match(/^[a-zA-Z]+:\\/\\//))
    s = 'http://' + s;

13. Extract URL link: the following expression can filter out the URL in a piece of text.

^(f|ht){1}(tp|tps):\\/\\/([\\w-]+\\.)+[\\w-]+(\\/[\\w- ./?%&=]*)?

14. File path and extension verification: verify the file path and extension under windows (in the following example,. txt file)


15. Extract Color Hex Codes: sometimes you need to extract color codes from web pages. You can use the following expression.


16. Extract web page picture: if you want to extract all picture information in the web page, you can use the following expression.

\\< *[img][^\\\\>]*[src] *= *[\\"\\']{0,1}([^\\"\\'\\ >]*)

17. Extract page hyperlink: extract the hyperlink in html.

(<a\\s*(?!.*\\brel=)[^>]*)(href="https?:\\/\\/)((?!(?:(?:www\\.)?'.implode('|(?:www\\.)?', $follow_list).'))[^"]+)"((?!.*\\brel=)[^>]*)(?:[^>]*)>

18. Find CSS properties: through the following expression, you can search for matching CSS properties.


19. Extract comments: if you need to remove comments from HMTL, you can use the following expression.


20. Match HTML tag: the tag attributes in HTML can be matched by the following expression.


Author: craftsman
Link: https://www.jianshu.com/p/e7bb97218946
Source: Jianshu

Keywords: Mobile IE Windows

Added by sols on Mon, 04 May 2020 03:23:55 +0300