1. Verify password strength
The strength of the password must be a combination of upper and lower case letters and numbers. Special characters cannot be used. The length is between 8-10.
var reg = /^(?=.*\\d)(?=.*[a-z])(?=.*[A-Z]).$/;
2. Verify Chinese
String can only be Chinese.
var reg = /^[\\u4e00-\\u9fa5]$/;
3. A string of numbers, 26 English letters or underscores
var reg = /^\\w+$/;
4. Verify E-Mail address
As with passwords, the following is a regular check statement for E-mail address compliance.
var reg = /[\\w!#$%&'*+/=?^_`{|}~-]+(?:\\.[\\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\\w](?:[\\w-]*[\\w])?\\.)+[\\w](?:[\\w-]*[\\w])?/;
5. Verify ID number
The following is the regular verification of ID number. 15 or 18 digits.
15 place:
var reg = /^[1-9]\\d((0\\d)|(1[0-2]))(([0|1|2]\\d)|3[0-1])\\d$/;
18 place:
var reg = /^[1-9]\\d[1-9]\\d((0\\d)|(1[0-2]))(([0|1|2]\\d)|3[0-1])\\d([0-9]|X)$/;
6. Verification date
Date verification in "yyyy MM DD" format, horizontal leap year has been considered.
var reg = /^(?:(?!0000)[0-9]-(?:(?: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](?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)-02-29)$/;
7. Verification amount
Amount verification, accurate to 2 decimal places.
var reg = /^[0-9]+(.[0-9])?$/;
8. Verify mobile phone number
The following is the domestic mobile phone number regular expression starting with 13, 15 and 18. (the first two numbers can be extended according to the current domestic collection number)
var reg = /^(13[0-9]|14[5|7]|15[0|1|2|3|5|6|7|8|9]|18[0|1|2|3|5|6|7|8|9])\\d$/;
9. Judge IE version
At present, ie has not been completely replaced. Many pages still need to be version compatible. The following is the expression of IE version check.
var reg = /^.*MSIE [5-8](?:\\.[0-9]+)?(?!.*Trident\\/[5-9]\\.0).*$/;
10. Verify IP-v4 address
IP4 regular statement.
var reg = /\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.)(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b/;
11. Verify IP-v6 address
IP6 regular statement.
var reg = /(([0-9a-fA-F]:)[0-9a-fA-F]|([0-9a-fA-F]:):|([0-9a-fA-F]:):[0-9a-fA-F]|([0-9a-fA-F]:)(:[0-9a-fA-F])|([0-9a-fA-F]:)(:[0-9a-fA-F])|([0-9a-fA-F]:)(:[0-9a-fA-F])|([0-9a-fA-F]:)(:[0-9a-fA-F])|[0-9a-fA-F]:((:[0-9a-fA-F]))|:((:[0-9a-fA-F])|:)|fe80:(:[0-9a-fA-F])%[0-9a-zA-Z]|::(ffff(:0):)((25[0-5]|(2[0-4]|1[0-9])[0-9])\\.)(25[0-5]|(2[0-4]|1[0-9])[0-9])|([0-9a-fA-F]:):((25[0-5]|(2[0-4]|1[0-9])[0-9])\\.)(25[0-5]|(2[0-4]|1[0-9])[0-9]))/;
12. Check the prefix of the URL
In application development, it is often necessary to distinguish whether the request is HTTPS or HTTP. You can get a url prefix through the following expression and then make a logical judgment.
var reg = /^[a-zA-Z]+:\\/\\//;
if (!s.match(/^[a-zA-Z]+:\\/\\//)) {
s = 'http://' + s;}
13. Extract URL link
The following expression filters out the URL s in a piece of text.
var reg = /^(f|ht)(tp|tps):\\/\\/([\\w-]+\\.)+[\\w-]+(\\/[\\w- ./?%&=]*)?/;
14. File path and extension verification
Verify the file path and extension under windows (the. txt file in the following example)
var reg = /^([a-zA-Z]\\:|\\\\)\\\\([^\\\\]+\\\\)*[^\\/:*?"<>|]+\\.txt(l)?$/;
15. Extract Color Hex Codes
Sometimes you need to extract the color code from the web page. You can use the following expression.
var reg = /^#([A-Fa-f0-9]|[A-Fa-f0-9])$/;
16. Extract web page pictures
If you want to extract all the picture information in the web page, you can use the following expression.
var reg = /\\< *[img][^\\\\>]*[src] *= *[\\\\']([^\\"\\'\\ >]*)/;
17. Extract page hyperlink
Extract hyperlinks from html.
var reg = /(<a\\s*(?!.*\\brel=)[^>]*)(href=""https?:\\/\\/)((?!(?:(?:www\\.)?'.implode('|(?:www\\.)?'3 December 2019, 06:40 | Views: 8911
Add new comment
0 comments