First: In Linux, the regular expression is for the content of the file. Check in the Shell's grep,sed, awk and other related commands.
Metacharacters of regular Expressions:
. : Represents any character
Number of characters anchor:
*: Indicates that * previous characters or patterns appear any time, including 0 times
? Said Before the characters appear 0 or one time, it should be noted that in Linux needs to be \?.
\{m,n\}: Indicates that the preceding character or pattern appears at least m times, up to N times
\{m,\}: Indicates that the characters preceding it appear at least m times
\{0,n\}: Indicates that the character preceding it appears at most n times
Location anchoring:
^: denotes the beginning of the character following it
$: Indicates the end of the character in front of it
^$: Indicates a matching blank line
Match words: (you need to be aware of the meaning of words.) Root is the word, R. T is not considered a word in Linuxshell)
\<word: Represents a word that matches the beginning of Word.
Word\>: Represents a word that matches the end of Word
\<word\>: Indicates that the word matches the complete word
Range Matching:
[0-9]: Indicates a matching number
[A-Z]: Indicates a matching lowercase letter
[A-Z]: indicates matching uppercase letters
[[:p UNCT:]]: Indicates matching punctuation
[[: Space:]]: Indicates matching whitespace characters
[[: Lower:]]: Indicates a matching lowercase letter
[[: Upper:]]: Indicates matching uppercase letters
[[: Alpha:]]: Indicates matching letters, not case-sensitive letters
[[:d Igit:]]: Indicates a matching number
[[: Alnum:]]: Indicates a matching number letter
It is important to note that range matching indicates that one character in a range can be matched. Reverse matching is also supported. [^[::]]
Summary of usage of regular expressions in Linux