Detect whole word in NSStrings
问题 How do I detect if an NSString contains a specific word, e.g. is . If the NSString is Here is my string. His isn't a mississippi isthmus. It is... ? The method should detect the word is and return YES . However, if the NSString is His isn't a mississipi isthmus , it should return NO . I tried using if ([text rangeOfString:@"is" options:NSCaseInsensitiveSearch].location != NSNotFound) { ... } but it detects characters not words. 回答1: Use "regular expression" search with the "word boundary