Hi,
I have a requirement where I have to avoid a particular
word in a sentence. Example-
word to avoid= "head"
I don't want this word to be in the
string. If I use indexOf() or contains() method, it also checks for headfirst or forehead, but this should be allowed. And if I use indexOf(" head ") or contains(" head "), then it will not check if I add only head as a word in string or if I write "head." i.e '.' after head. or if I use it with any special characters.
I think regular expression will help. But I haven't used regular expressions. Would be helpful if anyone can throw some light on this or better post the code snippet for the same.