17 Kinds of regular expressions
"^/d+$"//non-negative Integer (positive integer + 0)
"^[0-9]*[1-9][0-9]*$"//Positive integer
"^ ((-/d+) | (0+)) $ "//non-positive integer (negative integer + 0)
"^-[0-9]*[1-9][0-9]*$"//Negative integer
"^-?/d+$"//Integer
"^/d+ (/./d+)? $"//nonnegative floating-point number (positive float + 0)
"^ ([0-9]+/. [0-9]*[1-9][0-9]*) | ([0-9]*[1-9][0-9]*/. [0-9]+) | ([0-9]*[1-9][0-9]*)] $ "//Positive floating-point number
"^ ((-/d+ (/./d+)?) | (0+ (/.0+)) $ "//non-positive floating-point number (negative floating-point number + 0)
^ (-([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 number
"^ (-?/d+) (/./d+)? $"//floating-point number
"^[a-za-z]+$"//A string of 26 English letters
"^[a-z]+$"//A string of 26 uppercase letters
"^[a-z]+$"///a string consisting of 26 lowercase letters
"^[a-za-z0-9]+$"//A string of numbers and 26 English letters
"^/w+$"//A string of numbers, 26 English letters, or underscores
"^[/w-]+ (/.[ /w-]+) *@[/w-]+ (/.[ /w-]+) +$ "//email address
"^[a-za-z]+://(/w+ (-/w+) *) (/. ( /w+ (-/w+) *)) * (/?/s*) $ "//url
Match IP Address: (/d+)/. (/d+)/. (/d+)/. (/d+)/g/
Matching regular expressions for Chinese characters: [/U4E00-/U9FA5]
Match Double-byte characters (including Chinese characters): [^/x00-/xff]
A regular expression that matches a blank row:/n[/s|] */r
Regular expression matching HTML tags:/< (. *) >.*<///1>|< (. *)//>/
Matching a regular expression with a trailing space: (^/s*) | (/s*$)
Regular expression matching an email address:/w+ ([-+.] /w+) *@/w+ ([-.] /w+) */./w+ ([-.] /w+) *
A regular expression that matches URL URLs: ^[a-za-z]+://(//w+ (-//w+) *) (//.) ( w+ (-//w+) *)) * (//?//s*)? $
Match account number is legal (beginning of letter, allow 5-16 bytes, allow alphanumeric underline): ^[a-za-z][a-za-z0-9_]{4,15}$
Match domestic phone number: (/d{3}-|/d{4}-)? (/d{8}|/d{7})?
Matching Tencent QQ Number: ^[1-9]*[1-9][0-9]*$
Verify email Address: "^/w+ ([-+.] /w+) *@/w+ ([-.] /w+) */./w+ ([-.] /w+) *$ ".
Verify InternetURL: "^http://([/w-]+/.) +[/w-]+ (/[/w-./?%&=]*)? $ ".
Verify phone Number: "^ (/(/d{3,4}-) |/d{3.4}-)?/d{7,8}$" The correct format is: "Xxx-xxxxxxx", "xxxx-xxxxxxxx", "xxx-xxxxxxx", "xxx-xxxxxxxx", " XXXXXXX "and" XXXXXXXX ".
Verify ID Number (15-bit or 18-digit): "^/d{15}|/d{18}$".
Verify 12 months of the year: "^" (0?[ 1-9]|1[0-2]) $ "The correct format is:" 01 "~" 09 "and" 1 "~" 12 ".
Verify one months of 31 days: "^ (0?[ 1-9]) | ((1|2) [0-9]) |30|31) $ "the correct format is;" 01 "~" 09 "and" 1 "~" 31 ".
/marks the next character as a special character, or a literal character, or a back reference, or a octal escape character.
^ matches the start position of the input string. If the multiline property of the RegExp object is set, ^ also matches the position after ' n ' or ' R '.
$ matches the end position of the input string. If the multiline property of the RegExp object is set, the $ also matches the position before ' n ' or ' R '.
* Match the preceding subexpression 0 or more times.
+ matches the preceding subexpression one or more times. + is equivalent to {1,}.
? Match the preceding subexpression 0 times or once.? is equivalent to {0,1}.
{n} n is a non-negative integer that matches the determined N times.
{N,} n is a non-negative integer that matches at least n times.
{n,m} m and n are non-negative integers, where n <= m. Matches n times at least and matches up to M times. You cannot have spaces between commas and two numbers.
? When the character is immediately following any of the other qualifiers (*, +,?, {n}, {n,}, {n,m}), the matching pattern is not greedy. Non-greedy patterns match as few strings as possible, while the default greedy pattern matches as many of the searched strings as possible.
. Matches any single character except "/n". To match any character including '/n ', use a pattern like ' [. N] '.
(pattern) matches the pattern and gets the match.
(?:p Attern) matches pattern but does not get matching results, which means that this is a non fetch match and is not stored for later use.
(? =pattern) forward lookup, matching the find string at the beginning of any string matching pattern. This is a non-fetch match, that is, the match does not need to be acquired for later use.
(?! pattern) Negative forward check, contrary to (? =pattern) Effect
X|y matches x or Y.
[XYZ] Character set combination.
[^XYZ] Negative character set combination.
[A-z] character range that matches any character within the specified range.
[^a-z] A negative character range that matches any character that is not in the specified range.
/b matches a word boundary, which means the position between the word and the space.
/b matches a non word boundary.
/CX matches the control characters indicated by X.
/d matches a numeric character. equivalent to [0-9].
/d matches a non-numeric character. equivalent to [^0-9].
/F matches a page feed character. Equivalent to/x0c and/CL.
/n matches a newline character. Equivalent to/x0a and/CJ.
/R matches a return character. Equivalent to/x0d and/cm.
/s matches any white space characters, including spaces, tabs, page breaks, and so on. equivalent to [/f/n/r/t/v].
/S matches any non-white-space character. equivalent to [^/f/n/r/t/v].
/t matches a tab character. Equivalent to/x09 and/ci.
/V matches a vertical tab. Equivalent to/x0b and/ck.
/w matches any word character that includes an underscore. Equivalent to ' [a-za-z0-9_] '.
/w matches any non word character. Equivalent to ' [^a-za-z0-9_] '.
/XN matches N, where n is the hexadecimal escape value. The hexadecimal escape value must be a determined two digits long.
/num matches num, where num is a positive integer. A reference to the match that was obtained.
/n identifies a octal escape value or a back reference. N is a forward reference if you have at least N obtained subexpression before/n. Otherwise, if n is an octal number (0-7), then N is an octal escape value.
/NM identifies a octal escape value or a back reference. NM is a/nm if at least one of the preceded by the at least NM gets the subexpression before the If there are at least N fetches before/nm, then N is a back reference followed by a literal m. If all the preceding conditions are not satisfied, if both N and M are octal digits (0-7), then/nm will match octal escape value nm.
/NML if n is an octal number (0-3) and both M and L are octal digits (0-7), then the octal escape value NML is matched.
/un matches N, where N is a Unicode character represented in four hexadecimal digits
Name
[A-za-z '-´/s] {1,40}
John Doeo ' Dell
Verify the name. Up to 40 uppercase and lowercase letters are allowed, along with some special characters that are commonly used in names. This list can be adjusted.
Digital
^/d? (/d{3})/d?/d? (/d{3})/d? (/d{4}) $
(425)-555-0123
425-555-0123
425 555 0123
Verify the U.S. phone number.
Email
/w+ ([-+.] /w+) *@/w+ ([-.] /w+) */./w+ ([-.] /w+) *
someone@example.com
Verify the e-mail address.
Url
^ (HTTP|HTTPS|FTP)/://[a-za-z0-9/-/.] +/. [A-za-z] {2,3} (: [a-za-z0-9]*)?/? ([a-za-z0-9/-/._/?/,/'////+&%/$#/=~]) *$
Verify the URL.
Zip code
^ (/d{5}-/d{4}|/d{5}|/d{9}) $|^ ([a-za-z]/d[a-za-z]/d[a-za-z]/d) $
Verify that you are allowed to use 5 or 9 digits of U.S. ZIP code.
Password
^ (? =.*/d) (? =.*[a-z]) (? =.*[a-z]). {8,10}$
Verify strong passwords. The number of characters must be within the range of 8 to 10. You must include a combination of uppercase and lowercase letters and numbers, and you cannot use special characters.
Non-negative integer
/d+
0986
Validates an integer greater than 0.
Currency (non-negative)
"/d+ (/./d/d)?"
Verify the positive currency amount. Requires a two-digit number after the decimal point.
Currency (positive or negative)