Metacharacters and descriptions commonly used in regular expressions
Metacharacters |
Symbol name |
Description |
\ |
Back slash |
Escape character |
| |
Pipeline |
Or |
[] |
Square brackets |
Represents one of the characters in a specified range |
[^] |
Square brackets + Caret |
Match characters that are not within a specified group |
() |
Parentheses |
You can combine regular characters and metacharacters a character or an expression |
{} |
Curly Braces |
Specify a minimum or maximum number of matches for a leading expression, for example, a{3,4} will match "AAA" and "AAAA" |
^ |
Insert character |
Used to specify the header of the matching string, also known as the line header |
$ |
Dollar symbol |
Used to specify the tail of the matched string, also known as the end of line locator |
* |
Asterisk |
Matches 0 or more leading expressions, a * matches a string consisting of 0~n "a" |
?
|
Question mark |
Matches 0 or 1 leading expressions, a? Will match "a" or "AA" |
\< |
Backslash + Less Sign |
A word head locator, such as "\<ABC", represents all lines that contain words beginning with ABC |
\>
|
Backslash + greater than sign |
The ending locator, such as "\>ABC", represents all lines that contain words ending in ABC |
.
|
Point number |
Match any one character |
-
|
Minus sign |
Used to indicate a range of characters, such as [A-z] representing characters from ' a ' to ' Z ' |
Shell Note 4