DescriptionRegular Expression
URL[a-zA-z]+://[^\s]*
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 (With content or self-closing)<(.*)(.*)>.*<\/\1>|<(.*) \/>
Password (Composed of numbers, uppercase letters, lowercase letters, punctuation, at least one of each, minimum 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]
Landline Phone Number in Mainland China(\d{4}-|\d{3}-)?(\d{8}|\d{7})
Mobile Phone Number in Mainland China1\d{10}
Postal Code in Mainland China[1-9]\d{5}
ID Card Number in Mainland China (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+)?
Word not containing "abc"\b((?!abc)\w)+\b
DescriptionRegular Expression
Username/^[a-z0-9_-]{3,16}$/
Password/^[a-z0-9_-]{6,18}$/
Hex Value/^#?([a-f0-9]{6}|[a-f0-9]{3})$/
Email Address/^([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+\/>)$/
Unicode Range for Chinese Characters/^[u4e00-u9fa5],{0,}$/
Regular Expression for Matching Chinese Characters[\u4e00-\u9fa5]
Note: Matching Chinese characters can be tricky; this expression helps.
Matching Double-byte Characters (including Chinese characters)[^\x00-\xff]
Note: Can be used to calculate string length (double-byte characters count as 2, ASCII characters count as 1).
Regular Expression for Matching Blank Lines\n\s*\r
Note: Can be used to remove blank lines.
Regular Expression for Matching HTML Tags<(\S*?)[^>]*>.*?<\/\1>|<.*?/>
Note: Many online versions are inadequate; this one only matches some cases and struggles with complex nested tags.
Regular Expression for Matching Leading and Trailing Whitespace^\s*|\s*$
Note: Can be used to remove leading and trailing whitespace (including spaces, tabs, page breaks, etc.); very useful.
Regular Expression for Matching Email Addresses\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*
Note: Very useful for form validation.
Regular Expression for Matching URLs[a-zA-z]+://[^\s]*
Note: Many online versions are limited; this one should suffice.
Checking Validity of Account (Starts with a letter, allows 5-16 characters, letters, numbers, underscores)^[a-zA-Z][a-zA-Z0-9_]{4,15}$
Note: Very useful for form validation.
Matching Domestic Phone Numbers\d{3}-\d{8}|\d{4}-\d{7}
Note: Matches formats like 0511-4405222 or 021-87888822.
Matching QQ Numbers[1-9][0-9]{4,}
Note: QQ numbers start from 10000.
Matching Postal Codes in Mainland China[1-9]\d{5}(?!\d)
Note: Postal codes in Mainland China consist of 6 digits.
Matching ID Cards\d{15}|\d{18}
Note: ID cards in Mainland China are either 15 or 18 digits.
Matching IP Addresses\d+\.\d+\.\d+\.\d+
Note: Useful for extracting IP addresses.
Matching Specific Numbers:
^[1-9]\d*$// Matches positive integers
^-[1-9]\d*$// Matches negative integers
^-?[1-9]\d*$// Matches integers
^[1-9]\d*|0$// Matches non-negative integers (positive integers + 0)
^-[1-9]\d*|0$// Matches non-positive integers (negative integers + 0)
^[1-9]\d*\.\d*|0\.\d*[1-9]\d*$// Matches positive floating-point numbers
^-([1-9]\d*\.\d*|0\.\d*[1-9]\d*)$// Matches negative floating-point numbers
^-?([1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0)$// Matches floating-point numbers
^[1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0$// Matches non-negative floating-point numbers (positive floating-point + 0)
^(-([1-9]\d*\.\d*|0\.\d*[1-9]\d*))|0?\.0+|0$// Matches non-positive floating-point numbers (negative floating-point + 0)
Note: Useful when processing large amounts of data; be sure to adjust for specific applications.
Matching Specific Strings
^[A-Za-z]+$// Matches strings composed of 26 letters
^[A-Z]+$// Matches strings composed of 26 uppercase letters
^[a-z]+$// Matches strings composed of 26 lowercase letters
^[A-Za-z0-9]+$// Matches strings composed of numbers and 26 letters
^\w+$// Matches strings composed of numbers, 26 letters, or underscores
Character Description
\ Marks the next character as a special character, literal character, backreference, or octal escape. For example, "n" matches the character "n." "\n" matches a newline. The sequence "\\" matches "\" while "\(" matches "(".
^ Matches the start of the input string. If the Multiline property of the RegExp object is set, ^ also matches positions after "\n" or "\r".
$ Matches the end of the input string. If the Multiline property of the RegExp object is set, $ also matches positions before "\n" or "\r".
* Matches the preceding subexpression zero or more times. For example, "zo*" can match "z" and "zoo". * is equivalent to {0,}.
+ Matches the preceding subexpression one or more times. For example, "zo+" can match "zo" and "zoo", but not "z". + is equivalent to {1,}.
? Matches the preceding subexpression zero or one time. For example, "do(es)?" can match "do" or "does". ? is equivalent to {0,1}.
{n} n is a non-negative integer. Matches exactly n times. For example, "o{2}" cannot match "o" in "Bob", but can match two o's in "food".
{n,} n is a non-negative integer. Matches at least n times. For example, "o{2,}" cannot match "o" in "Bob", but can match 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}" will match the first three o's in "fooooood". "o{0,1}" is equivalent to "o?". Note that there cannot be spaces between the comma and the two numbers.
? When this character follows any other quantifiers (*,+,?, {n}, {n,}, {n,m}), the pattern is non-greedy. The non-greedy mode matches as little of the search 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's".
. Matches any single character except for "\n". To match any character including "\n", use a pattern like "[.\n]".
(pattern) Matches pattern and captures the match. The captured match can be accessed from the resulting Matches collection. In VBScript, use the SubMatches collection, and in JScript, use $0…$9 properties. To match parentheses, use "\(” or “\)”.
(?:pattern) Matches pattern but does not capture the match, meaning this is a non-capturing match. This is useful when using the alternation character “|” to combine different parts of a pattern. For example, "industr(?:y|ies)" is a more concise expression than "industry|industries".
(?=pattern) Positive lookahead. Matches a string at the start of the input that matches pattern. This is a non-capturing match and does not require the match 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 the next search for a match begins immediately after the last match rather than starting from the character after the lookahead.
(?!pattern) Negative lookahead. Matches a string at the start of the input that does not match pattern. This is also a non-capturing match. For example, "Windows(?!95|98|NT|2000)" matches "Windows" in "Windows3.1" but not in "Windows2000". Like lookahead, it does not consume characters.
x|y Matches x or y. For example, "z|food" matches "z" or "food". "(z|f)ood" matches "zood" or "food".
[xyz] Character class. Matches any one of the contained characters. For example, "[abc]" can match "a" in "plain".
[^xyz] Negative character class. Matches any character not contained. For example, "[^abc]" can match "p" in "plain".
[a-z] Character range. Matches any character within the specified range. For example, "[a-z]" matches any lowercase letter from "a" to "z".
[^a-z] Negative character range. Matches any character not within the specified range. For example, "[^a-z]" matches any character not between "a" and "z".
\b Matches a word boundary, i.e., the position between a word and a space. For example, "er\b" can match "er" in "never" but not in "verb".
\B Matches a non-word boundary. "er\B" can match "er" in "verb" but not in "never".
\cx Matches the control character indicated by x. For example, \cM matches a Control-M or carriage return. x must be a value from 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. The hexadecimal escape value 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. References the captured match. For example, "(.)\1" matches two consecutive identical characters.
\n Indicates an octal escape value or a backreference. If there are at least n captured subexpressions before n, n is a backreference. Otherwise, if n is an octal digit (0-7), n is an octal escape value.
\nm Indicates an octal escape value or a backreference. If there are at least nm captured subexpressions before nm, nm is a backreference. If there are at least n captures, then n is a backreference followed by the literal m. If neither condition is met, if both n and m are octal digits (0-7), \nm matches the octal escape value nm.
\nml If n is an octal digit (0-3), and m and l are octal digits (0-7), it matches the octal escape value nml.
\un Matches n, where n is a Unicode character represented by four hexadecimal digits. For example, \u00A9 matches the copyright symbol (©).
Your Footprints:

Friendly Links: PM EVE PM EVE