Regular Expression also calls Regexp. There are two classes regular expressions: Basic Regexp (BRE) and Extended Regexp (ERE). Regexp should be put in double quotation marks.
It can be categorized to:
Strings
. – Can be any character.
Sample: #cat /etc/fstab | grep "U..D" It returns the lines contains U, D and whatever 2 characters between its.
[] – Any specified single character.
Sample: #cat /etc/fstab | grep "U[UAB]ID" It returnes the lines contains U, I, D and U or A or B.
[^] – Any character except specified single character.
Sample: #cat /etc/fstab | grep "[^AB]ID" It returnes the lines contains I and D but no A or B in left.
[[:digit:]] – All digital characters.
[[:lower:]] – All lower case characters.
[[:upper:]] – All upper case characters.
[[:alpha:]] – All alphabet characters.
[[:alnum:]] – All alphnumeric characters.
[[:space:]] – All space.
[[:print:]] – All visible characters and space.
[[:blank:]] – Space and tab.
[[:punct:]] – Punctuation and symbols.
Counting
Location
Grouping