Reputation: 185
I know how to make a Java Scanner not care about the uppercase or lowercasing, but how do I make it so that it doesn't care about punctuation? I want to do this so that I don't have to type all of this:
if (mirioutput.equalsIgnoreCase("You're an idiot.") ||
mirioutput.equalsIgnoreCase("Your an idiot.") ||
mirioutput.equalsIgnoreCase("You're an idiot") ||
mirioutput.equalsIgnoreCase("Youre an idiot") ||)
{
//code goes here
}
By the way, I'm trying to make a Siri-like program that will respond to what you type, if you're wondering why the text says "You're an idiot."
Upvotes: 0
Views: 95
Reputation: 6574
you can remove all none alphabatical and digits characters
mirioutput = mirioutput.replaceAll("[^A-Za-Z9-0]","");
Upvotes: 2