Metacharacters |
Action |
Example |
\ B |
Match with a word boundary, that is, the position between the word and the space. |
Er \ B matches "er" in "never", but does not match "er" in "verb. |
\ B |
Non-boundary word match. |
Er \ B matches "er" in "verb", but does not match "er" in "never. |
\ D |
Match numeric characters. It is equivalent to [0-9]. |
In the search string "12 345", \ D {2} matches "12" and "34. \ D matches "1", "2", "3", "4", and "5. |
\ D |
Match non-numeric characters. It is equivalent to [^ 0-9]. |
\ D + matches "ABC" and "def" in "ABC123 Def. |
\ W |
Match any of the following characters: A-Z, a-Z, 0-9, and underline. It is equivalent to [A-Za-z0-9 _]. |
Search for the string "The quick brown fox ..." , \ W + matches "the", "quick", "brown", and "Fox. |
\ W |
Match any character except a-Z, a-Z, 0-9, and underline. It is equivalent to [^ A-Za-z0-9 _]. |
Search for the string "The quick brown fox ..." Medium, \ W + and "…" Matches all spaces. |
[XYZ] |
Character Set. Matches any specified character. |
[ABC] matches "A" in "plain. |
[^ XYZ] |
Reverse character set. Matches any unspecified character. |
[^ ABC] matches "P", "L", "I", and "n" in "plain. |
[A-Z] |
Character range. Matches any character in the specified range. |
[A-Z] matches any lowercase letter in the range from "A" to "Z. |
[^A-Z] |
Reverse character range. Matches any character that is not within the specified range. |
[^ A-Z] matches any character that is not in the range of "A" to "Z. |
{N} |
Exactly matchNTimes.NIt is a non-negative integer. |
O {2} does not match "O" in "Bob", but matches two "O" in "food. |
{N,} |
At least matchNTimes.NIt is a non-negative integer. * Equal to {0. + Is equal to {1. |
O {2,} does not match "O" in "Bob", but matches all "O" in "foooood. |
{N,M} |
Match at leastNTimes, upMTimes.NAndMIs a non-negative integer.N<=M. No space is allowed between commas and numbers. ? Equal to {0, 1. |
In the search string "1234567", \ D {123} matches "456", "", and "7. |
(Mode) |
AndModeMatch and save the match. You canExec MethodThe returned array element is used to retrieve the saved matching items. To match the parentheses (), use "\ (" or "\)". |
(Chapter | section) [1-9] matches "Chapter 5" and saves "chapter" for future use. |
(? :Mode) |
AndModeMatch, but do not save the match; that is, do not store the match for future use. This is useful for components that use the "or" character (|) combination mode. |
Industr (? : Y | ies. |
(? =Mode) |
Positive prediction first. After a match is found, the next match is searched before the match text. No matching items are saved for future use. |
^ (? =. * \ D). {} $ apply the following restrictions to the password: It must be between 4 and 8 characters in length and contain at least one number. In this mode,. * \ D is followed by any number of characters. For the search string "abc3qr", this matches "abc3. Starting from before (rather than after) the match,. {} matches a string containing 4-8 characters. This matches "abc3qr. ^ And $ specify the start and end positions of the search string. This will block matching when the search string contains any character other than the matching character. |
(?!Mode) |
Negative prediction first. Matching andModeUnmatched search string. After a match is found, the next match is searched before the match text. No matching items are saved for future use. |
\ B (?! Th) \ W + \ B matches words that do not start with "th. In this mode, \ B matches a word boundary. For the search string "quick", this matches the first space. (?! Th. This matches "Qu. From this match, \ W + matches a word. This matches "quick. |
\ CX |
MatchXIndicates the control character.XMust be in the A-Z or a-Z range. If this is not the case, it is assumed that C is the text "C" character itself. |
\ Cm matches Ctrl + M or a carriage return. |
\ XN |
MatchN,NIs a hexadecimal escape code. The hexadecimal escape code must be exactly two digits long. ASCII code can be used in regular expressions. |
\ X41 matches ". \ X041 is equivalent to "\ x04" with "1" (becauseNMust be exactly two digits ). |
\Num |
MatchNum,NumIs a positive integer. This is a reference to saved matches. |
(.) \ 1 matches two consecutive identical characters. |
\N |
Identifies an octal escape code or a reverse reference. If \NAt leastNCapture sub-expressions, thenNIs a reverse reference. Otherwise, ifNIs the eight-digit number (0-7), thenNIt is an octal escape code. |
(\ D) \ 1 matches two consecutive identical numbers. |
\Nm |
Identifies an octal escape code or a reverse reference. If \NmAt leastNmCapture sub-expressions, thenNmIs a reverse reference. If \NmAt leastNCapture subexpressionsNIs reverse reference, followed by textM. If none of the above conditions exists, whenNAndMWhen it is an octal digit (0-7 ,\NmMatch the octal escape codeNm. |
\ 11 matches the tab. |
\NML |
WhenNIt is an octal number (0-3 ),MAndLMatch the octal escape code when it is an octal digit (0-7 ).NML. |
\ 011 matches the tab. |
\ UN |
MatchN, WhereNIt is a Unicode Character in hexadecimal notation. |
\ U00a9 and copyright symbol (?) Match. |