Regular meta characters |
Mode meaning |
Case |
\ |
Usually used to turn off the special meaning of its subsequent characters and restore its original intent. |
\ (... \), where the parentheses represent only parentheses. |
. |
matches any single character. |
A.B, will match ABB, ACB, etc. |
* |
A single character that matches the 0-n before it. |
A*b, will match AB, AAB, Aaab and so on. |
^ |
Matches the immediately preceding regular expression, at the beginning of the row. |
^ab, will match the ABC, ABD, etc., but does not match the cab. |
$ |
Matches the regular expression immediately following the line at the end of the row. |
ab$, will match AB, cab, etc., but does not match ABC. |
[...] |
A square bracket expression that matches any character inside it. Where-the range of consecutive characters is represented, and the first character in square brackets has a reverse meaning, which matches any character that is not within the list (square brackets). If you want the] and-to indicate its original intent, you need to place it at the first character position of the square brackets, such as []ab] or [-ab], if both characters exist at the same time, it will be] placed at the first character position--placed at the tail end, such as []ab-]. |
[a-ba-z0-9!] Represents all uppercase and lowercase letters, numbers, and exclamation marks. [^ABC] represents all characters except A, B, and C. [Tt]om, can match Tom and Tom.] |
\{n,m\} |
An interval expression that matches the number of occurrences of a single character in front of it, \{n\} means repeated n times, and \{n,\} means at least repeated n times, and \{n,m\} means repeating n to M times. |
Ab\{2\} indicates that abb;ab\{2,\} represents ABB, ABBB, and so on. Ab\{2,4\} represents ABB, ABBB and ABBBB. |
\(...\) |
The pattern between parentheses is stored in a special "reserved space". You can store up to 9 independent sub-patterns in a single mode. Text that matches the sub-pattern can be reused in the same pattern by \1 the escape sequence to \9. |
\ (ab\). *\1 indicates that AB combinations occur two times, and there can be any number of characters between two times, such as Abcdab, Abab, and so on. |
{N,m} (ERE) |
Its function is equivalent to the above \{n,m\}, just no longer write \ Escape character. |
ab+ matches AB, ABBB, etc., but does not match a. |
+ (ERE) |
Compared to the preceding asterisk, + matches the 1-n instance of the preceding regular expression. |
|
? (ERE) |
Matches 0 or 1 of the preceding regular expression. |
AB only matches a or AB. |
| (ERE) |
Matches the regular expression before and after the | symbol. |
(AB|CD) match ab or CD. |
[: Alpha:] |
Matches an alphabetic character. |
[[: alpha:]!] The ab$ matches the cab, Dab, and!ab. |
[: Alnum:] |
Matches alphabetic and numeric characters. |
[[: Alnum:]]ab$ matches 1ab, AaB. |
[: Blank:] |
Matches the space and tab characters. |
[[: Alnum:]]ab$ matches 1ab, AaB. |
[: Cntrl:] |
Match control characters. |
|
[:d Igit:] |
Match numeric characters. |
|
[: Graph:] |
Matches a non-whitespace character. |
|
[: Lower:] |
Matches lowercase alphabetic characters. |
|
[: Upper:] |
Matches uppercase characters. |
|
[:p UNCT:] |
Match punctuation characters. |
|
[: Space:] |
Matches a blank (whitespace) character. |
|
[: Xdigit:] |
Matches a hexadecimal number. |
|
\w |
Matches any character that consists of letters and numbers, equivalent to [[: Alnum:]_] |
|
\w |
Matches any character that is not a letter or number, equivalent to [^[:alnum:]_] |
|
\<\> |
Matches the beginning and end of a word. |
\<read matching readme,me\> matching readme. |