character | illustrate |
\ | Mark the next character as a special character, text, backreference, or octal escape character. For example, "n" matches the character "n". "\n" matches the newline character. The sequence "\\" matches "\", "\(" matches"(". |
^ | Matches the location where the input string begins. If setRegExpThe object'sMultilineattribute, ^ will also match the position after "\n" or "\r". |
$ | Match the end of the input string. If setRegExpThe object'sMultilineProperties, $ will also match the position before "\n" or "\r". |
* | Matches the preceding character or subexpression zero or multiple times. For example, zo* matches "z" and "zoo". * is equivalent to {0,}. |
+ | Matches the preceding character or subexpression one or more times. For example, "zo+" matches "zo" and "zoo" but does not match "z". + is equivalent to {1,}. |
? | Matches the preceding character or subexpression zero or once. For example, "do(es)?" matches "do" in "do" or "does". ? Equivalent to {0,1} |
{n} |
n Yes, non-negative integers. Just matchnSecond-rate. For example, "o{2}" does not match "o" in "Bob", but matches two "o" in "food". |
{n,} |
n Yes, non-negative integers. At least matchn Second-rate. For example, "o{2,}" does not match "o" in "Bob" and all os in "fooooood". 'o{1,}' is equivalent to 'o+'. 'o{0,}' is equivalent to 'o*'. |
{n,m} |
mandnYes, non-negative integers, wheren <= m. At least matchnTime, at most matchmSecond-rate. For example, "o{1,3}" matches the first three os in "fooooood". 'o{0,1}' is equivalent to 'o?'. Note: You cannot insert spaces between commas and numbers. |
? | When this character is followed by any other qualifier (*, +,?, {n}、{n,}、{n,m}) After that, the matching pattern is "non-greedy". The "non-greedy" pattern matches the searched, shortest string as possible, while the default "grey" pattern matches the searched, longest string. For example, in the string "oooo", "o+?" matches only a single "o", and "o+" matches all "o". |
. | Match any single character except "\n". To match any character including "\n", use a pattern such as "[\s\S]". |
(pattern) | matchpatternand capture the matching subexpression. Available$0...$9Attributes retrieve captured matches from the result Matches collection. To match the bracket character ( ), use "\(" or "\)". |
(?:pattern) | matchpatternBut the subexpression of the match is not captured, i.e. it is a non-capture match and does not store the match for later use. This is useful for combining mode components with the "or" character (|). For example, the expression "industr(?:y|ies)" is more economical than "industry|industries". |
(?=pattern) | The subexpression that performs a forward prediction prior search, which matches the expressionpatternstring at the starting point of the string. It is a non-capture match, i.e. it cannot capture matches for later use. For example, "Windows (?=95|98|NT|2000)" matches "Windows" in "Windows 2000" and does not match "Windows" in "Windows 3.1". Prediction does not occupy characters, that is, after a match occurs, the next match's search follows the previous match, rather than after the character that makes up the prediction. |
(?!pattern) | The subexpression that performs a reverse prediction predecessor search, which matches are not in the matchpatternThe search string for the starting point of the string. It is a non-capture match, i.e. it cannot capture matches for later use. For example, "Windows (?!95|98|NT|2000)" matches "Windows" in "Windows 3.1" and does not match "Windows" in "Windows 2000". Prediction does not occupy characters, that is, after a match occurs, the next match's search follows the previous match, rather than after the character that makes up the prediction. |
x|y
| matchxory. For example, "z|food" matches "z" or "food". "(z|f)ood" matches "zood" or "food". |
[xyz] | Character set. Match any character contained. For example, "[abc]" matches "a" in "plain". |
[^xyz] | Reverse character set. Match any characters not included. For example, "[^abc]" matches "p" in "plain". |
[a-z] | Character range. Match any character in the specified range. For example, "[a-z]" matches any lowercase letters in the range "a" to "z". |
[^a-z] | Reverse range characters. Match any characters that are not within the specified range. For example, "[^a-z]" matches any character that is not in the range of "a" to "z". |
\b | Match a word boundary, that is, the position between the word and the space. For example, "er\b" matches "er" in "never", but does not match "er" in "verb". |
\B | Non-word boundary matching. "er\B" matches "er" in "verb", but not "er" in "never". |
\cx
| Match byxThe control character indicated. For example, \cM matches a Control-M or carriage return.xThe value of , must be between A-Z or a-z. If this is not the case, then c is assumed to be the "c" character itself. |
\d | Number character matching. Equivalent to [0-9]. |
\D | Non-numeric character matching. Equivalent to [^0-9]. |
\f | Page change matching. Equivalent to \x0c and \cL. |
\n | Line breaks match. Equivalent to \x0a and \cJ. |
\r | Match a carriage return character. Equivalent to \x0d and \cM. |
\s | Match any whitespace characters, including spaces, tabs, page breaks, etc. Equivalent to [ \f\n\r\t\v]. |
\S | Match any non-whitespace characters. Equivalent to [^ \f\n\r\t\v]. |
\t | Tab matching. Equivalent to \x09 and \cI. |
\v | Vertical tab matching. Equivalent to \x0b and \cK. |
\w | Match any character in word class, including underscores. Equivalent to "[A-Za-z0-9_]". |
\W | Any non-character matching. Equivalent to "[^A-Za-z0-9_]". |
\xn
| matchn, herenis a hexadecimal escape code. The hexadecimal escape code must be exactly two digits long. For example, "\x41" matches "A". "\x041" is equivalent to "\x04"&"1". Allows the use of ASCII code in regular expressions. |
\num
| matchnum, herenumis a positive integer. to capture the backreference of the match. For example, "(.)\1" matches two consecutive identical characters. |
\n | Identifies an octal escape code or backreference. if \nAt least there isna capture subexpression, thennis a backreference. Otherwise, ifnIt is an octal number (0-7), thennIt is an octal escape code. |
\nm
| Identifies an octal escape code or backreference. if \nmAt least there isnma capture subexpression, thennmis a backreference. if \nmAt least there isnA capture, thennIt's a backreference, followed bym. If the previous conditions do not exist, thenn andmWhen it is an octal number (0-7), \nmMatch octal escape codenm。 |
\nml
| whennis an octal number (0-3),mandlWhen it is an octal number (0-7), matches the octal escape codenml。 |
\un
| matchn,innIt is a Unicode character represented by four hexadecimal numbers. For example, \u00A9 matches the copyright symbol (©). |