Reputation: 8855
Is it possible to make a function that searchs a string for an exact substring so that it will only 'return true' if the exact string if found, not as part of a larger word?
NSString* search = @"tele";
NSString* stringOne = @"telephone";
NSString* stringTwo = @"tele phone";
NSString* stringThree = @"phone tele";
What I mean is: Is it possible to search for a string in a way that the NSString 'search' would be found in strings Two and Three, but not One?
Upvotes: 0
Views: 532
Reputation: 47729
Simplest approach is to append blanks (or whatever your separators are) to front and rear of both strings, then do the search.
Upvotes: 1
Reputation: 44
Try using the following function in the NSString class:
- (NSRange)rangeOfString:(NSString *)aString
Upvotes: 1