Regular expression (RE):
Basic Regular Expression BRE:grep and sed use,egrep and awk use
extended Regular expression:egrep and awk use
meaning of the basic special characters:
^tux matches lines starting with Tux (must appear first in sed and grep )
tux$ matches lines ending with Tux (the last one must appear in sed and grep )
. Matches any single character except newline characters (can match line breaks inawk )
*match a previous character 0 or more times (including the preceding character)
.*Match any character 0 or more times
[] matches any one of the characters contained in [XXX] , except for the following three, the other special characters are ordinary characters in [] .
[\x]use \ in [] to relay the meaning of special characters
[^x] matches any one of the characters not contained in [^xxx]
[x-x] matches any character in the specified range in [M-n]
\{n\}Matches the previous character N times (including the preceding character)
\{n,\}matches the preceding character at least n times (including the preceding character)
\{n,m\}matches the preceding character at least n times, up to m times (including the preceding character)
\escape character, convert special character to normal character
Extended Special character meanings: (used byegrep and awk )
+ match one of the preceding characters 1 or more times (including the preceding character)
? Match one of the preceding characters 0 or 1 occurrences (including the preceding character)
|specifies that a regular expression can be matched before or after it, that is, or
() Grouping of regular expressions, () you are considered as a whole
{n}Matches the previous character N times (including the preceding character)
{n,}matches the preceding character at least n times (including the preceding character)
{n,m}matches the preceding character at least n times, up to m times (including the preceding character)
Description: If it matches the previous character 0 times, including the preceding character: that is, 0 times in the pattern of the * before the character to be removed.
character class (for [] ):
[: alnum:] printable characters (including white space characters)
[: Alpha:] alphabetic character
[: blank:]Spaces and Tabs
[: Cntrl:] control character
[:d igit:] numeric characters
[: graph:] graphic characters (excluding space characters)
[: Lower:] lowercase characters
[:p rint:] printable characters (including white space characters)
[:p unct:] punctuation characters
[: space:] white space characters
[: Upper:] Uppercase characters
[: xdigit:] hexadecimal character
To be Continued ...
RE: Regular Expression