Reference: Sarwar et al, Unix the textbook, 2nd Edition, Addison-Wesley, 2005, Pp. 248-250
Name/Function | Operator | Example Usage | Meaning | Supported By |
Alternation | x or y or z | awk, egrep | ||
Any Character | Acom, Bcom, Ccom, acom, bcom, ccom, ... |
All | ||
Beginning of Line | A line that starts with x as the first character |
All | ||
Concatenation | x followed by y followed by z | All | ||
End of Line | A line that ends with x as the last character |
All | ||
Escape Sequence Cancels The special meaning of the next character following it |
An ordinary asterisk * | ed, sed, vi, awk, grep | ||
Delimiter: Marks the beginning or End of a Regular Expression |
Love, Lave, Live, Lose, ... | ed, sed, vi, awk | ||
Grouping | xy, xyxy, xyxyxy, ... | All | ||
Optional | 0 or exactly 1 of previous character: x, xy | Awk, egrep | ||
Word Anchor | word (not part of a larger substring) | All | ||
Repetition | match 0 or more of previous character: x, xy, xyy, xyyy, ... | All | ||
Repetition | match 1 or more of previous character: xy, xyy, xyyy, ... | Awk, egrep | ||
Repetition | match at least 6 and no more than 8 of previous character: xyyyyyy, xyyyyyyy, xyyyyyyyy |
All | ||
Set menu of what can match a single character position |
Hello, hello | All | ||
Set menu of what cannot match a single character position |
Jello, hello, bello, ... | All |
Regular Expression | Meaning | Examples |
/^Yes/ | The string Yes At The Beginning Of The Line |
Yes... Yesteryear ... Yesterday ... |
/th/ | The string th Anywhere In The Line |
the there path bathing |
/:$/ | A Line Ending With A Colon | ... the following: ... below: ... list of: |
/[0-9]/ | A Single Digit | 0 1 2 3 4 5 6 7 8 9 |
/[a-z] [0-9]/ | A Single Lower Case Letter Followed By A Single Digit |
a0 b1 c2 d3 e4 f5 w6 x7 y8 z9 |
/\.c/ | An Ordinary Period Character Followed By A 'c' |
lab1.c program1.c client.c server.c |
/[a-zA-Z ]*/ | Any String Containing Zero Or More Of: Upper And/Or Lower Case Letters And/Or Spaces Only |
Any String Without Numbers Nor Punctuation: e.g. Not 767-! |
Command | Meaning |
/ [0-9] / | Do A Forward Search For A Single Standalone Digit Character (Surrounded By Spaces) In The Current File; Digits That Are In Substrings Don't Match |
?\.c[1-7] ? | Do A Backward Search For Words Or Strings In Words That End In .c Followed By A Single Digit Between 1 And 7 Inclusive |
:1,$s/:$/./ | Search The Whole File And Substitute A Period Whenever A Colon At The End Of The Line Is Found |
:.,$s/^[Hh]ello /Greetings / | Search From The Current Line To the End Of The File For Hello Or hello At The Beginning Of The Line And Replace Either With Greetings |
:1,$s/^ *// | Search The Entire File For Any Leading Spaces At The Beginning Of All Lines And Delete Them |