===================================
Regular Expression Skill Assessment
===================================
-IAN! idallen@ncf.ca
Here are some descriptions of text manipulation problems of varying levels
of difficulty. These are all example of text and data manipulation.
Some problems may be solved using Unix utilities that don't use regular
expressions. Many of the problems require more than one Unix utility,
or the same utility used repeatedly.
To succeed in this course, you must be able to do all the Elementary
manipulations given here. You must be able to do most of the Basic
manipulations.
Elementary
1. Change the letters "dog" to "HORSE" everywhere it occurs on all
lines.
2. Change all occurrences of the letters "Man" at the beginning of a
line to "Person".
3. Change all occurrences of "stick" followed by any punctuation at the
end of a line to "Stick.". (The punctuation is replaced by a
period.)
4. Change all occurrences of "Dog" or "dog" to "COW".
5. Change all Canadian or American spellings of colour (color) to
"Color".
6. Double all vowels in every word on every line.
7. Triple the amount of space between every word.
8. Find and print lines that contain "dog" followed by any number of
digits then "cat".
9. Find and print lines that contain the letters "dog" followed anywhere
by the letters "cat".
10. Change all occurrences of one or more digits to the single word
"NUMBER".
11. Replace all occurrences of one or more blanks with a single blank.
12. Replace all occurrences of one or more tabs or blanks with a single
blank.
13. Remove the first 8 characters from every line.
14. Remove all leading blanks or tabs from all lines.
15. Remove all trailing blanks or tabs from all lines.
16. Replace all tab characters with eight spaces.
17. Change all punctuation so that the sentence period lies outside of
the closing double quote, e.g. "Hello there." becomes "Hello there".
18. Remove everything leading up to and including the last blank on each
line.
19. Remove everything including and after the first blank on each line.
20. Put double quotes around every occurrence of the phrase
"user-friendly".
Basic
1. Add an extra blank after every period at the end of a sentence.
2. Make sure that every period at the end of a sentence is followed by
exactly two blanks.
3. Truncate every line to ten characters.
4. Exchange the first 10 characters with the next 15 characters on every
line.
5. Exchange the first number with the second number on every line.
6. Remove all leading zeroes from the first number on each line. Don't
mishandle single digit zeroes.
7. Find and print lines that contain all the vowels in alphabetical
order, a before e before i before o before u. Test using /usr/dict/
words.
8. Find and print lines that contain all the vowels in any order. Test
using /usr/dict/words.
9. Change all occurrences of one or more digits surrounded by spaces to
the word "NUMBER" also surrounded by spaces.
10. Change only the second occurrence of a single blank to a colon in
each line.
11. Change the only the second-to-last single blank to a colon in each
line.
12. Change only the second occurrence of a string of one or more blanks
to a colon in each line.
13. Change only the second-to-last occurrence of a string of one or more
blanks to a colon in each line.
14. Remove all occurrences of HTML tags whose open and closing angle
brackets are on the same line (e.g.
,