I have a question in my app I have a String
which contain a word for search, then I use this word to search from a long Text, I want that all words that contain the searched word to return (e.g. WoRd = word = WORD). Thanks.
private static int countWords(String tstr1, String string)
{
int i = 0;
Scanner s = new Scanner(tstr1);
while (s.hasNext())
{
if (s.next().equals(string))
i++;
}
return i;
}
}
String tstr1
is the text and String string
is the searched key, now I want to count how many times the searched key is in text (to be case insensitive). Thanks