Consulte sintaxe de expressões regulares, metacaracteres, quantificadores, grupos e flags. Um guia rápido ao escrever ou depurar padrões.
| Regular Character | Description |
|---|---|
| \ | Marks the next character as a special character, or as an original character, or as a backward reference, or as an octal convert. For example, “n"Systems."n"。"\nMatches a line break. Lines.\\Matches.\"And..."\("and match."("。 |
| ^ | Matches the beginning of the input string. & matches &ldquao if the Multiline properties of RegExp objects are set;\n"or"\r"after position. |
| $ | Matches the end of the input string. If the Multiline properties of the RegExp object are set, the $ matches “\n"or"\r"Previous position. |
| * | Matches the previous subexpression zero times or more. For example, zo* matches “z"and..."zoo". *Equivalent to {0,}. |
| + | Matches the previous subexpression once or more. For example, “zo+"It matches."zo"and..."zoo"but no match."z". + Equivalent to {1,}. |
| ? | Matches the previous subexpression zero or once. For example, “do(es)?"Can match."does"or"does"Call."do".? Equivalent to 0. |
| {n} | nis a non-negative integer. Match OKnSecond. For example, “o{2}"No match."Bob"Call."o"But it matches."food"in two o's. |
| {n,} | nis a non-negative integer. At least matchnSecond. For example, “o{2,}"No match."Bob"Call."o"But it matches."foooood"In all o's."o{1,}"Equivalence equals"o+"。"o{0,}"and equals the price."o*"。 |
| {n,m} | mandnnon-negative integers, of whichn<=m. Minimum matchnSecond and maximum matchmSecond. For example, “o{1,3}"will match"fooooood"of the first three o."o{0,1}"Equivalence equals"o?". Please note that there is no room between commas and numbers. |
| ? | When the character follows any other limit (*, +, {)n},{n,},{n,mAfter that, the matching pattern is not greedy. The non-vory model matches the search string as little as possible, while the default greed pattern matches the search string as much as possible. For example, for string & ldquo;oooo","o+?"will match the individual."o"and..."o+"will match all."o"。 |
| . | Match “\n"Any single character other than that. Match to include."\n"Any characters of this character, please use like"(.|\n)"Model. |
| (pattern) | Matches the pattern and obtains this match. The resulting matches can be obtained from the generated Matches collection, using the SubMatches collection in VBScript, and $0… $9 properties in JScript. To match round brackets, use &ldquao;\("or"\)"。 |
| (?:pattern) | Matching pattern without a matching result, i.e. it is a non-acquisition match and is not stored for later use. This is used or the character “(|)"It's useful to combine the different parts of a pattern."industr(?:y|ies)# It's a match #industry|industries"Simplified expression. |
| (?=pattern) | Prechecking to be positive, matching the search string at the beginning of any string matching the pattern. This is a non-acquisition match, i.e. the match does not need to be accessed for later use. e.g. “Windows(?=95|98|NT|2000)"It matches."Windows2000"Call."Windows"but no match."Windows3.1"Call."Windows". The precheck does not consume characters, that is, the next matching search begins immediately after the last match after a match occurs, rather than starting after the character containing the precheck. |
| (?!pattern) | Prechecking to the negative, matching the search string at the beginning of any string that does not match the pattern. This is a non-acquisition match, that is, the match does not need to be retrieved for later use. For example, “Windows(?!95|98|NT|2000)"It matches."Windows3.1"Call."Windows"but no match."Windows2000"Call."Windows". The precheck does not consume characters, that is, the next matching search starts immediately after the last match after a match occurs, rather than starting after the character containing the precheck |
| (?<=pattern) | Inverse pre-screening is the opposite of positive pre-screening, but in the opposite direction.(?<=95|98|NT|2000)Windows"It matches."2000Windows"Call."Windows"but no match."3.1Windows"Call."Windows"。 |
| (?<!pattern) | Inverse negative pre-screening is the opposite of a positive-negative pre-screening category.(?<!95|98|NT|2000)Windows"It matches."3.1Windows"Call."Windows"but no match."2000Windows"Call."Windows"。 |
| x|y | Matches x or y. For example, “z|food"It matches."z"or"food"。"(z|f)ood"and match."zood"or"food"。 |
| [xyz] | character set. Match any character included. For example, “[abc]"Can match."plain"Call."a"。 |
| [^xyz] | negative values. Match any characters that are not included. e.g. “[^abc]"Can match."plain"Call."p"。 |
| [a-z] | character range. Match any character within the specified range. For example, “[a-z]"Can match."aHere.z"Any lowercase characters within the range. |
| [^a-z] | negative values range. Match any character that is not within the specified range. For example, “[^a-z]"can match any absence."aHere.z"Any character within the range. |
| \b | Matches a word boundary, that is, the location between a word and a space. For example, “er\b"Can match."never"Call."er"but no match."verb"Call."er"。 |
| \B | Matches the non-word boundary. “er\B"It matches."verb"Call."er"but no match."never"Call."er"。 |
| \cx | Matches the control character specified by x. For example, \cM matches a Control-M or a return sign. x must be one of A-Z or a-z. Otherwise, c is considered as & ldquo;c"The character. |
| \d | Matches a numerical character. The value is equal to [0-9]. |
| \D | Matches a non-numeric character. The value is [^0-9]. |
| \f | Matches a page break. The value is equal to \\x0c and \\cl. |
| \n | Matches a line break. The equivalent is \\x0a and \\cJ. |
| \r | Matches a return sign. The price is equal to \\x0d and \cm. |
| \s | Matches any blank characters, including spaces, tabs, page breaks, etc. The value is equal to [\f\r\t\v]. |
| \S | Matches any non-empty character. The value is equal to [^] \f\r\t\v]. |
| \t | Matches a tab. Equivalent to \\x09 and \cI. |
| \v | Matches a vertical tab. The price is equal to \\x0b and \\cK. |
| \w | Matches any word characters that include underlineds. The value is equal to “[A-Za-z0-9_]"。 |
| \W | Matches any non-word characters. Value equals “[^A-Za-z0-9_]"。 |
| \xn | Matchnof whichnis the hexadecimal conversion value. The hexadecimal conversion value must be long.\x41Matches.A"。"\x041"and equals the price."\x04&1". The regular expression can be coded using ASCII... |
| \num | Matchnumof whichnumis a positive integer. A reference to a match obtained. For example, “(.)\1"Finds two consecutive same characters. |
| \n | Identifys a octal conversion value or a later reference.nBefore at leastnsubexpression, thennTo quote backwards. Otherwise, ifnis the octal number (0-7), thennis a octal conversion value. |
| \nm | Identifys a octal conversion value or a later reference.nmAt least before.nmacquisition subexpression, thennmTo quote later.nmAt least before.nOther OrganisernFor a Back and Textm. If the conditions are not met, ifnandmOctal (0-7)nmMatches the octal conversion valuenm。 |
| \nml | Ifnis the octal number (0-3) andm and lAll octal numbers (0-7) matching the octal conversion valuenml。 |
| \un | Matchnof whichnis a Unicode character expressed in four hexadecimals. For example, \u00A9 matches the copyright symbol (©). |
| Username | /^[a-z0-9_-]{3,16}$/ |
|---|---|
| Password | /^[a-z0-9_-]{6,18}$/ |
| Password 2 | (?=^.{8,}$)(?=.*\d)(?=.*\W+)(?=.*[A-Z])(?=.*[a-z])(?!.*\n).*$ (consisting of numeric/facile/low letter/point symbol, all four must be in place, more than eight places) |
| Hex value | /^#?([a-f0-9]{6}|[a-f0-9]{3})$/ |
| /^([a-z0-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[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)/ /(?: (?: 25 [0-5] |2 [0-4] [01]? [0-9] [0-9]?) {3} (? 25 [0-5] |2 [0-4] [0-9] | [01]? [0-9]?) $/ or ((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?) |
| HTML Tag | / ^lt; ([a-z]+ ([^lt;] +)* (? > *) < \fm> \s+\gt;) $//<(.*)(.*)>.*<\/\1>|<(.*) \/> |
| Remove Code \\ Comment | (?<!http:|\S)//.*$ |
| Match two bytes (including Han) | [^\x00-\xff] |
| Han (char) | [\u4e00-\u9fa5] |
| Hanword range in Unicode code | /^[\u2E80-\u9FFF]+$/ |
| Chinese and full agglomerations (charts) | [\u3000-\u301e\ufe10-\ufe19\ufe30-\ufe44\ufe50-\ufe6b\uff01-\uffee] |
| Date (year-month-year) | (\d{4}|\d{2})-((0?([1-9]))|(1[1|2]))-((0?[1-9])|([12]([1-9]))|(3[0|1])) |
| Date (month/day/year) | ((0?[1-9]{1})|(1[1|2]))/(0?[1-9]|([12][1-9])|(3[0|1]))/(\d{4}|\d{2}) |
| Time (hours: minutes, 24 hours) | ((1|0?)[0-9]|2[0-3]):([0-5][0-9]) |
| Fixed telephone number in mainland China | (\d{4}-|\d{3}-)?(\d{8}|\d{7}) |
| Chinese mobile phone number | 1\d{10} |
| Chinese Postal Code | [1-9]\d{5} |
| Chinese mainland ID number (15 or 18) | \d{15}(\d\d[0-9xX])? |
| Non-negative integer (positive or zero) | \d+ |
| Positive | [0-9]*[1-9][0-9]* |
| Negative Integer | -[0-9]*[1-9][0-9]* |
| Integer | -?\d+ |
| Decimal | (-?\d+)(\.\d+)? |
| Empty Row | \\s*r or (editplus)* |
| QQQ number. | [1-9]\d{4,} |
| Do not include abc words | \b((?!abc)\w)+\b |
| Match trail blank characters | ^\s*|\s*$ |
| Edit Common | Below are some replacements for special Chinese (editplus) ^[0-9].*\n *[ * ]. * * [Practice] * ^[\s\S ]*\n ^[0-9]*\. ^[\s\S ]*\n <p[^<>*]> href="javascript:if\(confirm\('(.*?)'\)\)window\.location='(.*?)'" <span style=".[^"]*rgb\(255,255,255\)">.[^<>]*</span> <DIV class=xs0>[\s\S]*?</DIV> |
Regular expression syntax is your usual regular expression quick-check table, regular expression syntax query, common regular expression syntax, basic regular expression syntax, subexpression, regular expression qualifier, regular expression greed mode, regular expression not greed mode, control of string by simple and quick means.