Programming activity: Regular expressions (SOLUTION) NOTE: In some cases there are more than one regular expression that would work. 1) Exactly the word "bear" Filename : words.txt Total lines : 329359 Total words : 329359 Regex : bear Regex matches : 1 2) Words that contain "bear" Filename : words.txt Total lines : 329359 Total words : 329359 Regex : .*bear.* Regex matches : 169 3) Words that start with "pre" and end in "ing" Filename : words.txt Total lines : 329359 Total words : 329359 Regex : pre.*ing Regex matches : 142 4) Three letter words that start and end with a vowel (vowels = aeiou) Filename : words.txt Total lines : 329359 Total words : 329359 Regex : [aeiou].[aeiou] Regex matches : 181 5) 2, 3 or 4 letter words that start and end with a vowel (vowels = aeiou) Filename : words.txt Total lines : 329359 Total words : 329359 Regex : [aeiou].{0,2}[aeiou] Regex matches : 707 6) Words then end in one of the following contractions: 'll 're 'nt Filename : words.txt Total lines : 329359 Total words : 329359 Regex : .*('ll|'re|'nt) Regex matches : 34 7) Updates that start with "keith is " Filename : social.txt Total lines : 1000000 Total words : 10579039 Regex : keith is .* Regex matches : 2 8) Updates that do not contain any vowels (vowels = aeiou) Filename : social.txt Total lines : 1000000 Total words : 10579039 Regex : [^aeiou]+ Regex matches : 13 9) Updates that consist of three 3-letter words (word = a-z plus apostrophe) Filename : social.txt Total lines : 1000000 Total words : 10579039 Regex : [a-z']{3} [a-z']{3} [a-z']{3} Regex matches : 167 10) Updates that contain at least one word that is 20 or more characters long. Filename : social.txt Total lines : 1000000 Total words : 10579039 Regex : .*[a-z']{20,}.* Regex matches : 8 11) All three word updates. Filename : social.txt Total lines : 1000000 Total words : 10579039 Regex : [a-z']+ [a-z']+ [a-z']+ Regex matches : 40783 12) Updates that do not contain any vowels. Filename : social.txt Total lines : 1000000 Total words : 10579039 Regex : [^aeiou]+ Regex matches : 13 13) Updates with 30 or more words where the last word ends in the letter s. Filename : social.txt Total lines : 1000000 Total words : 10579039 Regex : ([a-z']+ ){29,}([a-z']*s) Regex matches : 2001 14) Updates containing the word sequence "are you" anywhere in the sentence (at the start, in the middle, at the end, or as the whole sentence). Filename : social.txt Total lines : 1000000 Total words : 10579039 Regex : (are you .*)|(.* are you .*)|(.* are you)|(are you) Regex matches : 1781 15) Updates containing at least one word in which the second-to-last letter is z (the z-word may be in the middle of the sentence or at the end). Filename : social.txt Total lines : 1000000 Total words : 10579039 Regex : (.*[a-z']+z[a-z'] .*)|(.*[a-z']+z[a-z']) Regex matches : 11553