^ Beginning of the line.
$ end of line.
. Any character other than the line break.
* The preceding character repeats 0 to several times.
. * Used to match all characters.
[] Define a set of characters that match any one by one characters in the group (note!) Just one within the group! )
[^] Performs an inverse operation on characters within a character group (without any one by one characters in a group)
^[] The line at the beginning of the string within the group.
^[^] A line that begins with a string that is not within a group.
[A-z] matches a lowercase letter.
[A-z] matches an uppercase letter.
[A-z] matches a lowercase and uppercase letter.
[0-9] matches a number of 0-9.
\< Match Word Header
\> match end of Word
(The definition of a word in the regular is that it is separated by a space or other special character, and successive strings are treated as words.) )
Expansion of the Regular:
? Previous characters match 0 or 1
+ Previous characters match 1 or more
| logic or, for example abc|def ABC or DEF
() parentheses, for grouping, example: A (Bc|de) f
The meaning is ABCF or adef.
S{n} s was repeated n times.
S{n,} s repeats at least n times, even more times.
S{n,m} s repeats at least n times and repeats at most m times.
POSIX-defined character classifications:
[: Alnum:] Alphanumeric characters.
Match range is [a-za-z0-9]
[: Alpha:] Alphabetic characters.
Match range is [a-za-z]
[: Blank:] Space or tab characters.
Match range is space and TAB key
[: Cntrl:] Control characters.
Match control keys such as ^m to press CTRL + V and press ENTER to output
[:d Igit:] Numeric characters.
Match all numbers [0-9]
[: Graph:] Characters that is both printable and visible. (A space is print-
Able, but no visible, while a-a is both.)
Matching all visible characters without spaces and tabs is all the symbols you can see with your eyes on your keyboard in a text document
[: Lower:] lower-case alphabetic characters.
lowercase [A-z]
[:p rint:] Printable characters (characters that is not control characters.)
Match all visible characters including spaces and tab
All symbols that can be printed on the paper
[:p UNCT:] Punctuation characters (characters, digits, con-
Trol characters, or space characters).
Special input symbol +-=) (*&^%$#@!~ ' |\ "' {}[]:;? />.<,
Note that it does not contain spaces and tab
This set is not equal to ^[a-za-z0-9]
[: Space:] Space characters (such as space, tab, and FormFeed, to name a few).
[: Upper:] Upper-case alphabetic characters.
uppercase [A-z]
[: Xdigit:] Characters that is hexadecimal digits.
16 binary number [0-f]
How to use:
[[email protected] ~]# grep--color ' [[: Alnum:]] '/etc/passwd
This article is from the "Rebirth" blog, make sure to keep this source http://suhaozhi.blog.51cto.com/7272298/1909379
Regular expression collation of Linux text processing