A basic regular expression
? and () are extended regular expressions.
Two "*" before the character match 0 times, or any number of times
Three "." match any character except newline
Four "^" match the beginning of the line, "$" match the end of the line
Five "[]" matches any character specified in the brackets, only one character
Six "[^]" matches any character except the characters in brackets
Seven "\" escape characters
“\.$”
Match lines ending with "."
Eight "\{n\}" means that the preceding character appears exactly n times
Nine "\{n,\}" means that the preceding character appears no less than n times
Ten "\{n,m\}" means that the preceding character appears at least n times and at most m times
Eleven sample documents
a
aa
aaa
yyyy
aaaaa
c
cc
xcccu
xccccu
xcccccu
said
soid.
mouth
soooooooooood.
12345
5678
7832
bbbbbb45bbbb
6aaaaaaaaaaaaaa
away
aabb
Twelve Match Date and IP
[root@localhost ~]# grep "[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}" test.txt
2016-02-14
[root@localhost ~]# vim test.txt
[root@localhost ~]# grep "[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}" test.txt
192.108.4.2
194.6.3.98