Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Regular expression question in Linux: 1. Write a regular expression that you cou

ID: 3891005 • Letter: R

Question

Regular expression question in Linux:

1. Write a regular expression that you could use with egrep that will find all entries in /usr/share/dict/words that contain the sequence ‘aa’, ‘ii’ or ‘uu’ consecutively. Only write the regular expression. Do not include the egrep command and do not enclose it in single or double quotes.

2. Write a regular expression that you could use with egrep that will find all entries in /usr/share/dict/words that have two consecutive punctuation marks. Only write the regular expression. Do not include the egrep command and do not enclose it in single or double quotes.

Explanation / Answer

1)
[aa|ii|uu]*
Here it will match the pattern with aa ii or uu .
| symbol defines the OR that is it will match either aa ii uu the exists and the symbol * defines one or more time.

2)
the regex can be as follows:
[.',":;][.',":;]+
here it means that it will exist one time that is checked from the 1st square bracket.
the orther square bracket checks that it again exists for the 2nd time atleast once. Atleast once is implemented using the sign +