Regular Character | Description |
---|---|
\ | Marks the next character as a special character, or a literal character, or a backward reference, or an octal escape character. For example, "n" matches the character "n". "\n" matches a newline character. The series "\\" matches "\", and "\(" matches "(". |
^ | Matches the start 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 previous subexpression zero or more times. For example, "zo*" can match "z" and "zoo". * is equivalent to {,}. |
+ | Matches the previous subexpression once or more times. For example, "zo+" can match "zo" and "zoo", but not "z". + is equivalent to {1,}. |
? | Matches the previous subexpression zero or one time. For example, "do(es)?" can match "do" in "does" or "do". |
{n} | n is a non-negative integer. Matches exactly n times. For example, "o{2}" cannot match the "o" in "Bob", but can match the two "o"s in "food". |
{n,} | n is a non-negative integer. Matches at least n times. For example, "o{2,}" cannot match the "o" in "Bob", but can match all the "o"s in "foooood". "o{1,}" is equivalent to "o+". "o{,}" is equivalent to "o*". |
{n,m} | Both m and n are non-negative integers, with 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{,1}" is equivalent to "o?". Note that there should be no space between the comma and the two numbers. |
? | When this character follows any other quantifier (*, +, ?, {n}, {n,}, {n,m}), the matching pattern is non-greedy. Non-greedy mode matches as few of the searched string as possible, while the default greedy mode matches as many 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 the pattern and captures the match. The captured match can be obtained from the resulting Matches collection, using the SubMatches collection in VBScript, and using the $…$9 properties in JScript. To match the parentheses characters, use "“\( " or "“\) ". |
(?:pattern) | Matches the pattern but does not capture the match result, meaning it is a non-capturing match and not stored for later use. This is useful when using the alternation operator "“(|) " to combine parts of a pattern. For example, "“industr(?:y|ies) " is a more concise expression than "“industry|industries ". |
(?=pattern) | Positive lookahead assertion, matches the search string at the beginning of any string that matches the pattern. This is a non-capturing match, meaning the match does not need to be captured for later use. For example, "“Windows(?=95|98|NT|2000) " can match "“Windows " in "“Windows2000 ", but not "“Windows " in "“Windows3.1 ". Lookahead assertions do not consume characters, meaning that after a match occurs, the next match search begins immediately after the last match, not after the character containing the lookahead. |
(?!pattern) | Negative lookahead assertion, matches the search string at the beginning of any string that does not match the pattern. This is a non-capturing match, meaning the match does not need to be captured for later use. For example, "“Windows(?!95|98|NT|2000) " can match "“Windows " in "“Windows3.1 ", but not "“Windows " in "“Windows2000 ". Lookahead assertions do not consume characters, meaning that after a match occurs, the next match search begins immediately after the last match, not after the character containing the lookahead. |
(?<=pattern) | Positive lookbehind assertion, similar to positive lookahead assertion but in the opposite direction. For example, "“(?<=95|98|NT|2000)Windows " can match "“Windows " in "“2000Windows ", but not "“Windows " in "“3.1Windows ". |
(?<!pattern) | Negative lookbehind assertion, similar to negative lookahead assertion but in the opposite direction. For example, "“(?<!95|98|NT|2000)Windows " can match "“Windows " in "“3.1Windows ", but not "“Windows " in "“2000Windows ". |
x|y | Matches x or y. For example, "“z|food " can match "“z " or "“food ". "“(z|f)ood " matches "“zood " or "“food ". |
[xyz] | Character class. Matches any one of the characters contained. For example, "“[abc] " can match "“a " in "“plain ". |
[^xyz] | Negated 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] " can match any lowercase letter character from "“a " to "“z ". |
[^a-z] | Negated character range. Matches any character not within the specified range. For example, "“[^a-z] " can match any character not within the range from "“a " to "“z ". |
\b | Word boundary.
Matches a word boundary, which refers to the position between a word and a space. For example, "“er\b " can match "“er " in "“never ", but cannot match "“er " in "“verb ". |
\B | Matches a non-word boundary. "“er\B " can match "“er " in "“verb ", but cannot match "“er " 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 [-9]. |
\D | Matches a non-digit character. Equivalent to [^-9]. |
\f | Matches a form feed. Equivalent to \xc and \cL. |
\n | Matches a newline character. Equivalent to \xa and \cJ. |
\r | Matches a carriage return. Equivalent to \xd and \cM. |
\s | Matches any whitespace character, including space, tab, form feed, 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 \x9 and \cI. |
\v | Matches a vertical tab character. Equivalent to \xb and \cK. |
\w | Matches any word character including the underscore. Equivalent to "“[A-Za-z-9_] ". |
\W | Matches any non-word character. Equivalent to "“[^A-Za-z-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 "“\x4&1 ". ASCII codes can be used in regular expressions. |
\num | Matches num, where num is a positive integer. A reference to the captured match. For example, "“(.)\1 " matches two consecutive identical characters. |
\n | Identifies an octal escape value or a backward reference. If there are at least n captured subexpressions before \n, then n is a backward reference. Otherwise, if n For octal digits (-7), then n is an octal escape value. |
nm | Identifies an octal escape value or a backward reference. If there are at least nm captured subexpressions before \nm, then nm is a backward reference. If there are at least n captures before \nm, then n is a backward reference followed by the literal m. If neither of the previous conditions is met, and if n and m are both octal digits (-7), then \nm will match the octal escape value nm. |
nml | If n is an octal digit (-3), and m and l are both octal digits (-7), then match 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 (©). |
Username | /^[a-z-9_-]{3,16}$/ |
---|---|
Password | /^[a-z-9_-]{6,18}$/ |
Password2 | (?=^.{8,}$)(?=.*\d)(?=.*\W+)(?=.*[A-Z])(?=.*[a-z])(?!.*\n).*$ (composed of numbers/uppercase letters/lowercase letters/punctuation, all four are necessary, more than 8 digits) |
Hexadecimal Value | /^#?([a-f-9]{6}|[a-f-9]{3})$/ |
/^([a-z-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})$/ /^[a-z\d]+(\.[a-z\d]+)*@([\da-z](-[\da-z])?)+(\.{1,2}[a-z]+)+$/ or \w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)* | |
URL | /^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/ or [a-zA-z]+://[^\s]* |
IP Address | /((2[-4]\d|25[-5]|[1]?\d\d?)\.){3}(2[-4]\d|25[-5]|[1]?\d\d?)/ /^(?:(?:25[-5]|2[-4][-9]|[1]?[-9][-9]?)\.){3}(?:25[-5]|2[-4][-9]|[1]?[-9][-9]?)$/ or ((2[-4]\d|25[-5]|[1]?\d\d?)\.){3}(2[-4]\d|25[-5]|[1]?\d\d?) |
HTML Tag | /^<([a-z]+)([^<]+)*(?:>(.*)<\/\1>|\s+\/>)$/ or <(.*)(.*)>.*<\/\1>|<(.*) \/> |
Remove Code \ Comments | (?<!http:|\S)//.*$ |
Match Double-byte Characters (including Chinese characters) | [^\x00-\xff] |
Chinese Characters (Characters) | [\u4e00-\u9fa5] |
Range of Chinese Characters in Unicode Encoding | /^[\u2E80-\u9FFF]+$/ |
Chinese and Full-width Punctuation (Characters) | [\u3000-\u301e\ufe10-\ufe19\ufe30-\ufe44\ufe50-\ufe6b\uff1-\uffee] |
Date (Year-Month-Day) | (\d{4}|\d{2})-((?([1-9]))|(1[1|2]))-((?[1-9])|([12]([1-9]))|(3[|1])) |
Date (Month/Day/Year) | ((?[1-9]{1})|(1[1|2]))/(?[1-9]|([12][1-9])|(3[|1]))/(\d{4}|\d{2}) |
Time (Hour:Minute, 24-hour format) | ((1|?)[-9]|2[-3]):([-5][-9]) |
Mainland China Fixed-line 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 Number (15 or 18 digits) | \d{15}(\d\d[-9xX])? |
Non-negative Integer (Positive Integer or Zero) | \d+ |
Positive Integer | [-9]*[1-9][-9]* |
Negative Integer | -[-9]*[1-9][-9]* |
Integer | -?\d+ |
Decimal | (-?\d+)(\.\d+)? |
Blank Line | \n\s*\r or \n\n (editplus) or ^[\s\S ]*\n |
QQ Number | [1-9]\d{4,} |
Word Not Containing 'abc' | \b((?!abc)\w)+\b |
Match Leading and Trailing Whitespaces | ^\s*|\s*$ |
Common Edits | Here are some special Chinese replacements (editplus) ^[-9].*\n ^[^Section].*\n ^[Exercise].*\n ^[\s\S ]*\n ^[-9]*\. ^[\s\S ]*\n <p[^<>*]> href="javascript:if\(confirm\('(.*?)'\)\)window\.location='(.*?)'" <span style=".[^"]*rgb\(255,255,255\)">.[^<>]*</span> <DIV class=xs>[\s\S]*?</DIV> |
Regular Expression Syntax is your quick reference guide for commonly used regular expressions, regular expression syntax query, common regular expression syntax, basic regular expression syntax, sub-expression syntax, regular expression modifiers, regular expression greedy mode, regular expression non-greedy mode, achieving control over strings through simple and fast methods.
Friendship link: Online Tool Network masters tool Calculation Assistant mathematical calculator ipsaya Random IP Strong Random Password Generator 2 to the power of what is 1/64 Globe Ask hello wordl Live Clock Numbers to Letters Pokemon Guide Snail Bob Red Light Green Light Game Excel Game Block Blast Unblocked Incredibox Sprunki Today Lucky Number Military Time Chart Chronological Age Calculator 12 Weeks From Today Weeks From Today Bottleneck Calculator Letters to Numbers