~/ learn/ comp-325/ cards/ Regular expressions: literals plus operators
1 of 9

Run the three worked-example patterns over the candidate file

Run the three worked-example patterns over the candidate file

Answer

grep -E 'a|bc*' candidates grep -E '(a|b)*' candidates grep 'L..e' candidates

The first prints every line containing an a, or a b with any number of trailing c characters. The second prints all six lines, because zero repetitions is a legal match and every line contains the empty string. The third needs a literal L, exactly two characters, then a literal e.

Sarwar & Koretsky 3e ch7 §7.5; POSIX.1-2024 XBD §9 (BRE and ERE)

space flip · ← → navigate · esc to exit
NORMAL ~/memra/library/451509a4-4a8f-4bf6-8d89-6b3e524ece6a/flashcard utf-8 LF