Description Regular expression
URL [a-zA-z]+://[^\s]*
IP address(IP Address) ((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)
Email address \w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*
QQ number [1-9]\d{4,}
HTML tag (including content or self-closing) <(.*)(.*)>.*<\/\1>|<(.*) \/>
Password (composed of digits/uppercase letters/lowercase letters/punctuation, all four required, at least 8 characters) (?=^.{8,}$)(?=.*\d)(?=.*\W+)(?=.*[A-Z])(?=.*[a-z])(?!.*\n).*$
Date (year-month-day) (\d{4}|\d{2})-((1[0-2])|(0?[1-9]))-(([12][0-9])|(3[01])|(0?[1-9]))
Date (month/day/year) ((1[0-2])|(0?[1-9]))/(([12][0-9])|(3[01])|(0?[1-9]))/(\d{4}|\d{2})
Time (hour:minute, 24-hour format) ((1|0?)[0-9]|2[0-3]):([0-5][0-9])
Chinese characters [\u4e00-\u9fa5]
Chinese and full-width punctuation (characters) [\u3000-\u301e\ufe10-\ufe19\ufe30-\ufe44\ufe50-\ufe6b\uff01-\uffee]
Mainland China landline phone number (\d{4}-|\d{3}-)?(\d{8}|\d{7})
Mainland China mobile phone number 1\d{10}
Mainland China postal code [1-9]\d{5}
Mainland China ID card number (15 or 18 digits) \d{15}(\d\d[0-9xX])?
Non-negative integer (positive integer or zero) \d+
Positive integer [0-9]*[1-9][0-9]*
Negative integer -[0-9]*[1-9][0-9]*
Integer -?\d+
Decimal (-?\d+)(\.\d+)?
Words that do not contain abc \b((?!abc)\w)+\b
Description Regular expression
Username /^[a-z0-9_-]{3,16}$/
Password /^[a-z0-9_-]{6,18}$/
Hexadecimal value /^#?([a-f0-9]{6}|[a-f0-9]{3})$/
Email /^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})$/
URL /^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/
IP address /^(?:(?: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]?)$/
HTML tag /^<([a-z]+)([^<]+)*(?:>(.*)<\/\1>|\s+\/>)$/
Range of Chinese characters in Unicode encoding /^[u4e00-u9fa5],{0,}$/
Regular expression to match Chinese characters [\u4e00-\u9fa5]
Comment: Matching Chinese is really a headache, with this expression it becomes easier
Match double-byte characters (including Chinese characters) [^\x00-\xff]
Comment: Can be used to calculate the length of a string (a full-width character counts as 2, ASCII characters count as 1)
Regular expression to match blank lines \n\s*\r
Comment: Can be used to delete blank lines
Regular expression to match HTML tags <(\S*?)[^>]*>.*?</\1>|<.*?/>
Comment: The version circulating online is terrible; the above can only match part, and is still powerless for complex nested tags
Regular expression to match leading and trailing whitespace characters ^\s*|\s*$
Comment: Can be used to delete whitespace at the beginning and end of lines (including spaces, tabs, form feeds, etc.), a very useful expression
Regular expression to match email addresses \w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*
Comment: Very practical for form validation
Regular expression to match URLs [a-zA-z]+://[^\s]*
Comment: The version circulating online has limited functionality; the above basically meets the needs
Match whether the account is valid (starting with a letter, allowing 5-16 bytes, allowing letters, numbers, underscores) ^[a-zA-Z][a-zA-Z0-9_]{4,15}$
Comment: Very practical for form validation
Match domestic telephone numbers \d{3}-\d{8}|\d{4}-\d{7}
Comment: Matches forms like 0511-4405222 or 021-87888822
Match Tencent QQ number [1-9][0-9]{4,}
Comment: Tencent QQ numbers start from 10000
Match Mainland China postal code [1-9]\d{5}(?!\d)
Comment: Mainland China postal codes are 6 digits
Match ID card \d{15}|\d{18}
Comment: Mainland China ID cards are 15 or 18 digits
Match IP address \d+\.\d+\.\d+\.\d+
Comment: Useful when extracting IP addresses
Match specific numbers:
^[1-9]\d*$ // Match positive integer
^-[1-9]\d*$ // Match negative integer
^-?[1-9]\d*$ //Match integer
^[1-9]\d*|0$ // Match non-negative integer (positive integer + 0)
^-[1-9]\d*|0$ // Match non-positive integer (negative integer + 0)
^[1-9]\d*\.\d*|0\.\d*[1-9]\d*$ // Match positive floating point number
^-([1-9]\d*\.\d*|0\.\d*[1-9]\d*)$ // Match negative floating point number
^-?([1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0)$ // Match floating point number
^[1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0$ // Match non-negative floating point number (positive floating point number + 0)
^(-([1-9]\d*\.\d*|0\.\d*[1-9]\d*))|0?\.0+|0$ // Match non-positive floating point number (negative floating point number + 0)
Comment: Useful when processing large amounts of data, pay attention to corrections in specific applications
Match specific strings
^[A-Za-z]+$ // Match a string consisting of 26 English letters
^[A-Z]+$ // Match a string consisting of uppercase 26 English letters
^[a-z]+$ // Match a string consisting of lowercase 26 English letters
^[A-Za-z0-9]+$ // Match a string consisting of digits and 26 English letters
^\w+$ // Match a string consisting of digits, 26 English letters, or underscores
Character Description
\ Marks the next character as a special character, a literal character, a backreference, or an octal escape. For example, \"n\" matches the character \"n\". \"\n\" matches a newline. The sequence \"\\\" matches \"\\" and \"\(\" matches \"(\".
^ Matches the beginning 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 of the input string. If the Multiline property of the RegExp object is set, $ also matches the position before \"\n\" or \"\r\".
* Matches the preceding subexpression zero or more times. For example, zo* matches \"z\" and \"zoo\". * is equivalent to {0,}.
+ Matches the preceding subexpression one or more times. For example, \"zo+\" matches \"zo\" and \"zoo\", but not \"z\". + is equivalent to {1,}.
? Matches the preceding subexpression zero or one time. For example, \"do(es)?\" matches \"do\" in \"do\" or \"does\". ? is equivalent to {0,1}.
{n} n is a non-negative integer. Matches exactly n times. For example, \"o{2}\" does not match the \"o\" in \"Bob\", but matches the two o's in \"food\".
{n,} n is a non-negative integer. Matches at least n times. For example, \"o{2,}\" does not match the \"o\" in \"Bob\", but matches all o's in \"foooood\". \"o{1,}\" is equivalent to \"o+\". \"o{0,}\" is equivalent to \"o*\".
{n,m} m and n are non-negative integers, where n <= m. Matches at least n times and at most m times. For example, \"o{1,3}\" matches the first three o's in \"fooooood\". \"o{0,1}\" is equivalent to \"o?\". Note that there can be no spaces between the comma and the numbers.
? When this character follows any other quantifier (*, +, ?, {n}, {n,}, {n,m}), the matching mode is non-greedy. Non-greedy mode matches as little of the searched string as possible, while the default greedy mode matches as much as possible. For example, for the string \"oooo\", \"o+?\" will match a single \"o\", while \"o+\" will match all \"o\".
. Matches any single character except \"\n\". To match any character including \"\n\", use a pattern like \"[.\n]\".
(pattern) Matches pattern and captures the match. The captured match can be obtained from the generated Matches collection, using the SubMatches collection in VBScript, or the $0...$9 properties in JScript. To match parentheses characters, use \"\(\" or \"\)\".
(?:pattern) Matches pattern but does not capture the match, meaning it is a non-capturing match and is not stored for later use. This is useful when using the or character \"(|)\" to combine parts of a pattern. For example, \"industr(?:y|ies)\" is a simpler expression than \"industry|industries\".
(?=pattern) Positive lookahead: matches at the beginning of a string that matches pattern. This is a non-capturing match, meaning it does not need to be captured for later use. For example, \"Windows(?=95|98|NT|2000)\" matches \"Windows\" in \"Windows2000\", but not in \"Windows3.1\". Lookahead does not consume characters, meaning after a match occurs, the search for the next match starts immediately after the last match, not after the characters involved in the lookahead.
(?!pattern) Negative lookahead: matches at the beginning of a string that does not match pattern. This is a non-capturing match, meaning it does not need to be captured for later use. For example, \"Windows(?!95|98|NT|2000)\" matches \"Windows\" in \"Windows3.1\", but not in \"Windows2000\". Lookahead does not consume characters, meaning after a match occurs, the search for the next match starts immediately after the last match, not after the characters involved in the lookahead.
x|y Matches x or y. For example, \"z|food\" matches \"z\" or \"food\". \"(z|f)ood\" matches \"zood\" or \"food\".
[xyz] Character set. Matches any one of the enclosed characters. For example, \"[abc]\" matches the \"a\" in \"plain\".
[^xyz] Negated character set. Matches any character not enclosed. For example, \"[^abc]\" matches the \"p\" in \"plain\".
[a-z] Character range. Matches any character in the specified range. For example, \"[a-z]\" matches any lowercase letter in the range a to z.
[^a-z] Negated character range. Matches any character not in the specified range. For example, \"[^a-z]\" matches any character not in the range a to z.
\b Matches a word boundary, i.e., the position between a word and a space. For example, \"er\b\" matches the \"er\" in \"never\", but not in \"verb\".
\B Matches a non-word boundary. \"er\B\" matches the \"er\" in \"verb\", but not in \"never\".
\cx Matches a control character specified by x. For example, \cM matches a Control-M or carriage return. The value of x must be one of A-Z or a-z. Otherwise, c is treated as a literal \"c\" character.
\d Matches a digit character. Equivalent to [0-9].
\D Matches a non-digit character. Equivalent to [^0-9].
\f Matches a form-feed character. Equivalent to \x0c and \cL.
\n Matches a newline character. Equivalent to \x0a and \cJ.
\r Matches a carriage return character. Equivalent to \x0d and \cM.
\s Matches any whitespace character, including spaces, tabs, form feeds, etc. Equivalent to [\f\n\r\t\v].
\S Matches any non-whitespace character. Equivalent to [^\f\n\r\t\v].
\t Matches a tab character. Equivalent to \x09 and \cI.
\v Matches a vertical tab character. Equivalent to \x0b and \cK.
\w Matches any word character including 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 a hexadecimal escape value. Hexadecimal escape values must be exactly two digits long. For example, \"\x41\" matches \"A\". \"\x041\" is equivalent to \"\x04&1\". ASCII encoding can be used in regular expressions.
\num Matches num, where num is a positive integer. A backreference to the captured match. For example, \"(.)\1\" matches two consecutive identical characters.
\n Identifies an octal escape value or a backreference. If \n is preceded by at least n captured subexpressions, then n is a backreference. Otherwise, if n is an octal digit (0-7), then n is an octal escape value.
\nm Identifies an octal escape value or a backreference. If \nm is preceded by at least nm captured subexpressions, then nm is a backreference. If \nm is preceded by at least n captures, then n is a backreference followed by literal m. If none of the previous conditions are met, and n and m are both octal digits (0-7), then \nm matches the octal escape value nm.
\nml If n is an octal digit (0-3), and m and l are both octal digits (0-7), then match the octal escape value nml.
\un Matches n, where n is a Unicode character expressed in four hexadecimal digits. For example, \u00A9 matches the copyright symbol (©).
Your Footprints: