Java help - Replace all if string contains multiple substrings
So there's a really old guy teaching Java at my college, and I have not learned a thing. He set a 1 day deadline to write something that we don't even know about. The book is worthless as well.
Here we're inputting a string and searching for 3 words to take out. However, it this only works if all 3 words are inserted. I can't even think straight anymore...after 3 straight hours of staring at my screen.
This is so similar to PHP but so many different exceptions >.< and tight rules.
Scanner keyboard = new Scanner(System.in);
String v1 = keyboard.nextLine();
String dog = "dog";
String cat = "cat";
String llama = "llama";
String result = v1.replaceAll("(?i)dog ", "");
String result2 = result.replaceAll("dog ", "");
String result3 = result2.replaceAll("(?i)cat ", "");
String result4 = result3.replaceAll("cat", "");
String result5 = result4.replaceAll("(?i)llama ", "");
String result6 = result5.replaceAll("llama ", "");
Thanks for your help