using System; using System.Text.RegularExpressions; namespace LabPuppy5 { public class StoogeParser { static void Main(string[] args) { Regex regularExpression; MatchCollection allOfThem; regularExpression = new Regex("curly|larry|moe", RegexOptions.IgnoreCase); string stoogeText = "I was wondering if you could help me find the film clip which opens" + " with the stooges snoring, then Moe waking up and telling the others to" + " 'wake up and go to sleep'. Answer: There are a number of Three Stooges Shorts" + " that have them snoring. In the episode 'If A Body Meets A Body' Moe said to Larry " + "'Wake up and go to sleep!' and in 'Hold that Lion' Moe also said it to Larry." + "They used to do comedy sketches when they were younger and Curly had Moe tape" + " lines to his forehead so he could remember them."; allOfThem = regularExpression.Matches(stoogeText); StoogeSighting[] sightings = new StoogeSighting[100]; int index = 0; foreach (Match oneMatch in allOfThem) { sightings[index] = new StoogeSighting(oneMatch.Value, oneMatch.Index); index++; } for(int i = 0; i < index; i++) { Console.WriteLine(sightings[i].giveName() + " " + sightings[i].givePlace()); } } } }