Lab Assignment

Total assignment value: 25 points
For each of the following questions, use the shortest regular expression that you can construct which will still answer the question
  1. show a pattern to match any vowel:
  2. show a pattern to match a, b or c:
  3. show a pattern to match the numbers 2 through 7:
  4. show a pattern to match the usernames root, rot and rooooot:
  5. show a pattern to match redwood, RedWood, redWood or Redwood at the end of a line:
  6. show a pattern to match redwood, fruitwood or hardwood:
  7. show a pattern to match redwood, fruitwood or hardwood, but not nutwood:
  8. show a pattern to match any number of characters at the beginning of a line, followed by a colon:
  9. show a pattern to match any number of characters at the beginning of a line, followed by a colon, an asterisk, and a colon:
  10. show a pattern to match any number of characters at the beginning of a line, followed by a colon, an asterisk, a colon, and any number of zeroes (e.g. toor:*:000 or root:*:0 :
  11. show a pattern to match any line ending in jpg or jpeg:
  12. show a pattern to match any line ending in jpg or jpeg, any case:
  13. show a pattern to match dll, asp or exe at the end of a line:
  14. what characters would match 'food' as a subexpression?
  15. how would one refer to the second defined subexpression?
  16. Using sed, replace all instances of red with blue. Show the sed instruction:
  17. (2 points) Replace the word 'red' with green in all instances of the phrase 'the quick red fox jumped', found in the file regexp_datafile.txt at http://ccis2161.linux-classes.com/labs/regexp_datafile.txt . Show the syntax of the sed instruction you used:
  18. replace 'mauled' with 'presented an award to' in the previously mentioned datafile:

  19. (3 points) In each instance of the phrase 'the quick red fox jumped over the lazy brown dog' found in the previously mentioned file, replace all instances of 'red fox' with 'blue frog', and replace 'lazy brown' with 'morbidly obese'. Nothing else should be changed in the file.

  20. (3 points) Perform the same substitution you did in the previous question, but this time, only do it on the FIRST occurance of the phrase in the file: