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

FOR UNIX: Given the regular expression, what is the correct matching pair? ( the

ID: 3864829 • Letter: F

Question

FOR UNIX: Given the regular expression, what is the correct matching pair? ( the answers to choose from are after the '>>' symbols)

1.) [ABC][^AB] >> A, AB, ADBC, D, or none

2.) ^[ABC][AB]$ >> A, AB, ADBC, D, or none

3.) ^[ABC][^AB]$ >> A, AB, ADBC, D, or none

4.) bc.*: >> aaabbbcccddd, aaaabcsssss, aaaabc, aabbss, or none

5.) bc*. >> aaabbbcccddd, aaaabcsssss, aaaabc, aabbss, or none

6.) ^[a-z]… >> abcdefg, a:237efg, AbcDefg, afe, or none

7.) ..{3}$ >> rs.ef$tt, abc.ab, abc.$$$$, abc, or none

8.) s:?s* >> efgs:sgfe, ssssssssss, rsts, abc, or none

9.) :?.? >> :a?????????, eeeeeefffff?hhhh, aaa::??????, :?.?, or none

10.) [^$]$ >> $$$$$$aaaaaa, bcdef$, $, abc,or none

11.) ^[^$]*$ >> $$$$$$aaaaaa, bcdef$, $, abc, or none

12.) ^[^$]$ >> $$$$$$aaaaaa, bcdef$, $, abc, or none

13.) $[0-9]$ >> $$$$$$, $10, abc$, $, or none

14.) ^$[0-9][0-9]$ >>    $10, abc$, $, or none

Explanation / Answer

1. A- This is the only match because it is one character in the set [A,B,C]

2. D- This is the only match because it is one character that is NOT A, B, or C

3. A,D - These match because they are one character between A and G, inclusive

4. A, AB - These match because they must start with a character that is A,B, or C due to ^[ABC]. They also must end with a character that is A or B due to [AB]$. Both A and AB match.

5. None - There are no matches because none of them start with bc. There are substrings that match, however, but the question was unclear. For a match to occur, a pattern would start with bc and then contain any string afterward.

6. None - There are no matches because none of them start with b. There are substrings that match, however, but the question was unclear. For a match to occur, a pattern would start with b and then contain any number of c's, then contain a single character (any one).

7. $$$$$$aaaaaa, abc - These match because their last character is not "$". The character denotes that $ should be taken literally, and there's a ^ in front, so it means not. $ is at the end, so it means the last character can be anything but "$".

8. abc - This matches because it both starts and ends with a character that is not "$". [^$] denotes any character except $. ^ before says it must start with that and $ at the end means it has to end with that. abc is the only one that works.

9. Same question as #7

10. $10 - This matches because it starts with "$" and ends with two numbers. ^$ means start with a literal "$" character. And [0-9][0-9]$ means it must end with two characters that are between 0 and 9, inclusive. "$10" is the only one that works.

11. $$$$$$, $35f - these match because they have to start with "$" due to ^$. [0-9]* means that any number (even 0) of number characters between 0 and 9 can follow. Then it must end with a character that is not a number, due to [^0-9]$.