The attached:Regular lookup table

An expression for a checksum number

  • The Numbers:^ [0-9] * $
  • N digits:^\d{n}$
  • A number with at least n digits:^\d{n,}$
  • M-n digits:^\d{m,n}$
  • Numbers beginning with zero and non-zero:^ (0 | [1-9] [0-9] *) $
  • Non-zero numbers with at most two decimal digits:^ ((1-9] [0-9] *) + (. [0-9] {1, 2})? $
  • A positive or negative number with 1-2 decimal places:^ (\)? \ d + (\ \ d {1, 2})? $
  • Positive, negative, and decimal numbers:^ (\ | \ +)? \d+(\.\d+)? $
  • A positive real number with two decimal places:^ [0-9] + (. [0-9] {2})? $
  • A positive real number with 1 to 3 decimal places:^ [0-9] + (. [0-9] {1, 3})? $
  • Positive non-zero integers:^[1-9]\d*$^ ((1-9] [0-9] *) ${1, 3}^ \ +? [1-9] [0-9] * $
  • Negative integers that are not zero:^ \ [1-9] [] 0-9 "* $^-[1-9]\d*$
  • Non-negative integers:^\d+$^[1-9]\d*|0$
  • Non-positive integers:^-[1-9]\d*|0$^((-\d+)|(0+))$
  • Non-negative floating point numbers:^\d+(\.\d+)? $^[1-9]\d*\.\d*|0\.\d*[1-9]\d*|0? \. | 0 0 + $
  • Non-positive floating point numbers:^((-\d+(\.\d+)?) | (0 + (\. 0 +)? ) $^(-([1-9]\d*\.\d*|0\.\d*[1-9]\d*))|0? \. | 0 0 + $
  • Positive floating point numbers:^[1-9]\d*\.\d*|0\.\d*[1-9]\d*$^ (([0-9] + \. [0-9] * [1-9] [0-9] *) | ([0-9] * [1-9] [0-9] * \ [0-9] +) | ([0-9] * [1-9] [0-9] *)) $
  • Negative floating point:^-([1-9]\d*\.\d*|0\.\d*[1-9]\d*)$^ (- (([0-9] + \. [0-9] * [1-9] [0-9] *) | ([0-9] * [1-9] [0-9] * \ [0-9] +) | ([0-9] * [1-9] [0-9] *))) $
  • Floating point Numbers:^ (-? \d+)(\.\d+)? $^ -? ([1-9]\d*\.\d*|0\.\d*[1-9]\d*|0? $\. | 0 + 0)

An expression to validate a character

  • Chinese characters:^[\u4e00-\u9fa5]{0,}$
  • English and Figures:^[A-Za-z0-9]+$^ [A Za - z0-9] 40 {4} $
  • All characters from 3 to 20:^. {3, 20} $
  • The value is a string of 26 letters:^[A-Za-z]+$
  • A string consisting of 26 uppercase English letters:^[A-Z]+$
  • A string consisting of 26 lowercase letters:^[a-z]+$
  • A string of 26 letters and numbers:^[A-Za-z0-9]+$
  • A string of 26 letters, digits, and underscores (_) :^\w+$^ \ w {3, 20} $
  • Chinese, English and digits including underscores (_) :^[\u4E00-\u9FA5A-Za-z0-9_]+$
  • Chinese, English, numerals but not underscores:^[\u4E00-\u9FA5A-Za-z0-9]+$^ [\ u4E00 - \ u9FA5A - Za - z0-9] {2, 20} $
  • Can be entered with ^%&’,; =?\x22]+`
  • Do not enter characters containing ~ :[^~\x22]+

Special requirement expression

  • Email address: ^ \ w + (\ w + / – +.]) * @ \ w + ([-] \ w +) * \ \ w + ([-] \ w +) * $

  • Domain name: [a – zA – Z0-9] [9] – a – zA – Z0 – on conversion {0} (/. [a zA – Z0-9] [9] – a – zA – Z0 – on conversion {0}) + /.?

  • InternetURL: [a zA – z] + : / / [^ \ s] * or ^ http:// ([-] \ w + \.) +[\w-]+(/[\w-./?%&=]*)? $

  • Mobile phone number: ^ (13 [0-9] [0-9] | | 14 15 [0-9] | 166 | 17 [0-9] 18 [0-9] | | 19 [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, 8} $

  • Home phone number (0511-4405222, 021-87888822) : \ d {3} – \ d {8} | \ d {4} – \ d {7}

  • 18 id number (Numbers, the letter “x” at the end) : ^ ((\ d {and}) | (x [0-9] {18}) | (x [0-9] {18})) $

  • Account is (legal letter, allow 5-16 bytes, allow alphanumeric underlined) : ^ [a zA – Z] [a zA – Z0-9 _] {4, 15} $

  • Password (must start with a letter and contain only letters, digits, and underscores (_).) : ^[a-za-z]\w{5,17}$

  • Strong password (must contain uppercase and lowercase letters and digits, cannot use special characters, and is between 8 and 10 characters in length) : ^(? =.*\d)(? =.*[a-z])(? =. * [a-z]). 8, 10 {} $

  • Date format: ^\d{4}-\d{1,2}-\d{1,2}

  • The twelve months of the year (01 ~ 09 and 1 ~ 12) : ^(0? [1-9] [2-0]) $| 1

  • 31 days of a month (01 ~ 09 and 1 ~ 31) : ^((0? [1-9]) | | 2 (1) ([0-9]) | | 31) $30

  • Input format of money:

    • There are four forms of money we can accept :”10000.00″ and “10,000.00”, and “10000” and “10,000” without “cent” :^ (1-9] [0-9] * $
    • This means any number that does not start with 0, but it also means that a character “0” does not pass, so we use the following form:^ (0 | [1-9] [0-9] *) $
    • A 0 or a number that doesn’t start with 0. We can also allow a minus sign at the beginning:^ (0 | -? [1-9] [0-9] *) $
    • This represents a 0 or a number that might be negative and doesn’t start with a 0. Let the user start with 0. Let’s get rid of the minus, because money can’t be negative. Here’s what we’ll add to illustrate the possible decimals:^ [0-9] + (. [0-9] +)? $
    • It must be noted that there should be at least one digit after the decimal point, so “10.” will not pass, but “10” and “10.2” will pass:^ [0-9] + (. [0-9] {2})? $
    • So let’s say we have to have two decimal places behind the decimal point, and if you think that’s too harsh, you can do this:^ [0-9] + (. [0-9] {1, 2})? $
    • This allows the user to write only one decimal place. Now it’s time to consider commas in numbers. We can do this:^ [0-9] {1, 3} ([0-9] {3}), * (. [0-9] {1, 2})? $
    • 1 to 3 numbers, followed by any comma +3 numbers, make the comma optional, not mandatory:^ ([0-9] + | [0-9] {1, 3} ([0-9] {3}), * (. [0-9] {1, 2})? $
  • ^([a-za-z]+-?) +[a-zA-Z0-9]+\\.[x|X][m|M][l|L]$

  • Regular expressions for Chinese characters: [u4e00-u9fa5]

  • Double byte characters: [^\x00-\ XFF] (including Chinese characters, can be used to calculate the length of the string (a double byte character length 2, ASCII character 1))

  • Regular expression for blank lines: \n\s*\r (can be used to delete blank lines)

  • Regular expressions for HTML tags: <(\S*?) [^ >] * >. *? < 1 > / \ | <. *? /> < span style = “max-width: 100%; clear: both; min-height: 1em;

  • Fore and aft blank characters of regular expressions: ^ | \ \ s * s * $or (^ \ s *) | (\ s * $) (can be used to delete rows first line of white space characters (including Spaces, tabs, form-feed character, etc.), very useful expressions)

  • Tencent QQ id: [1-9][0-9]{4,} (Tencent QQ ID starts from 10000)

  • China Postcode: [1-9]\d{5}(? ! \d) (6-digit Postal code for China)

  • IP address: \d+\.\d+\.\d+\.\d+ (useful for extracting IP addresses)

  • IP address :((? : (? :25[0-5]|2[0-4]\\d|[01]? \\d? \\d)\\.) {3} (? :25[0-5]|2[0-4]\\d|[01]? \\d? \\d))

supplement

Characters to be escaped in a regular expression

$matches the end of the input string. If the Multiline property of the RegExp object is set, then $also matches \n’ or \r. To match the $character itself, use \$

() marks the start and end of a subexpression. Subexpressions can be retrieved for later use. To match these characters, use \(, \)

* Matches the preceding subexpression 0 or more times. To match the * character, use \*

+ matches the preceding subexpression 1 or more times. To match the + character, use \+

Matches any single character except newline \n. To match., use \.

[] marks the beginning of a bracketed expression. To match [, use \[

? Matches the preceding subexpression 0 or 1 times, or specifies a non-greedy qualifier. To match? Character, please use \?

\ Marks the next character as a special character, literal character, backreference, one of the octal escape characters. For example, n matches the character n and \n matches the newline character. The sequence \\ matches \, while \(matches (

^ Matches the start of the input string unless used in a square bracket expression, in which case it indicates that the set of characters is not accepted. To match ^ character itself, use \^

{} marks the beginning of a qualifier expression. To match {, use \{

| indicate a choice between the two. To match |, please use the \ |