IGDev Ok, if you want your app to do something when a word is found in a sentence? It doesnt make sense to convert that word to something else first.
So if 'tree' is found in the sentence, you can do something if it finds the word 'tree'. You dont have to make it '()' then do something on '()'. Are you using 'tree' or 'beans' as examples of swear words? Do you want to notify the user of the app that they have entered swear words?
If you explain as best you can what you want to do when words are found, I might be able to help more