I was wondering how I could check whether a complete word substring exists inside a string. As a concrete example, I would like to be able to replace the word minute with foo, and the word minutes with bar.
Currently, I am using to check whether a substring exists using:
if ([text rangeOfString:word].location != NSNotFound){
NSLog(@"Word is found");
}
However, the issue I have is that since the substring minute is always first detected, then minutes, I will always get the replacement foo, but never bar. How would I be able to detect whether the entire substrings exists in a string?
Thanks!
minutes, and then attemptminute. This way you'd never end withfoosin any string.rangeOfStringthat I could use?