Can someone help me with this regular expression problem for my system level pro
ID: 3668771 • Letter: C
Question
Can someone help me with this regular expression problem for my system level programming class? I solve the first one using the command egrep 'Jabberwock' Jabberwocky.txt (last image below). I need help with 2-7. Thanks
Design a simple pipeline of commands that will match the following outputs. A correct answer will match the output exactly an incorrect answer will not.
Possible commands you may want to look at: cat, more, less, grep, fgrep, egrep
You may also want to look at file i/o redirection with > and <
You can have multiple simple regex expressions in a pipeline chain instead of one all encompassing regex to accomplish a task. There are many possible solutions.
Explanation / Answer
Heres an example of regular expression groups:
The poem is the first part of Lewis Carrolls Jabberwocky, from Through the Looking Glass. You can see that the regular expression pattern has a number of parenthesized groups, consisting of any number of non-whitespace characters (S+) followed by any number of whitespace characters (s+). The goal is to capture the last three words on each line; the end of a line is delimited by $. However, the normal behavior is to match $ with the end of the entire input sequence, so we must explicitly tell the regular expression to pay attention to newlines within the input. This is accomplished with the (?m) pattern flag at the beginning of the sequence (pattern flags will be shown shortly).
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.