I'd like to parse a string in order to see if it matches the entire string or a substring. I tried this:
String [] array = {"Example","hi","EXAMPLE","example","eXamPLe"};
String word;
...
if ( array[j].toUpperCase().contains(word) || array[j].toLowerCase().contains(word) )
System.out.print(word + " ");
But my problem is:
When user enter the word "Example"
(case sensitive) and in my array there is "Example"
it doesn't print it, it only prints "EXAMPLE"
and "example"
that's because when my program compares the two strings it converts my array[j]
string to uppercase or lowercase so it won't match words with both upper and lower cases like the word "Example".
So in this case if user enters "Examp"
I want it to print:
Example EXAMPLE example eXamPLe