Finding a Word in a sentence (Word doesn't matter what case it is)
807597Mar 20 2005 — edited Mar 20 2005Greetings,
I am trying to find a method that would find a word in a sentence. I know that if you do sentence.indexOf("word"), you could tell where the word "word" is in the text. But what if the sentence is:
The Word is the way.
If I did sentence.indexOf("word"), it would return a -1, because "word" is not in the sentence. I can't just do sentence.indexOf("Word") because the user could type in something like:
The WOrd is the way.
And it wouldn't find the letters. So how can I make a code that would find a word in a sentence, and that it doesn't matter what the case of the word is. Thanks.
--Arran G.