A regular expression is a string composed of letters, numbers and special symbols that defines one or more strings. They are used to specify text patterns for searching. A regular expression is said to match any string it defines. The major capabilities include:
Regular expressions are used by the UNIX commands vi, ed, grep, awk, and sed. grep in fact stands for global regular expression printer.
For a complete discussion of regular expressions refer to a UNIX reference manual but, to get you started, we include a table of special characters that can be used in expressions. Note that regular expression special characters are similar to but not identical to those used in filename expansion.
. Any single character$ End of line
" Delimits operator characters to prevent interpretation
Turns off special meaning of a single character following
Represents 0 or more occurrences of the preceding character
![]()
Specifies character classes
^ Match only if string is at the beginning of a line
? Matches any one character
Matches any one of the characters enclosed in square brackets
Matches any character other than one of the characters that follow the exclamation mark within square brackets.
The string .* represents 0 or more characters, since . is any character and * is 0 or more occurrences.