java - Find whether a string matches another string -


i'd parse string in order see if matches entire string or substring. 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 problem is:

when user enter word "example" (case sensitive) , in array there "example" doesn't print it, prints "example" , "example" that's because when program compares 2 strings converts array[j] string uppercase or lowercase won't match words both upper , lower cases word "example".

so in case if user enters "examp" want print:

example example example example 

you can convert both input string , candidates uppercase before calling contains().

if ( array[j].touppercase().contains( word.touppercase() ) ) {     system.out.print(word + " "); } 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -