I need to find a word or several words. With this method, however, I find also piece of word.
NSString *searchString = [NSString stringWithFormat:@"%@",searchField.text];
NSRange range = [textString rangeOfString : searchString];
if (range.location != NSNotFound) {
NSLog(@"textString = %@", textString);
}
I need the word / words exact
How can I do?
Thank you!
There are various ways of parsing/finding sub-strings in NSString:
catfromcatapultwhen searching forcat.… and they, of course, each have their PROs and CONs.
NSString has 9 methods grouped under “Finding Characters and Substrings”. Methods such as:
NSRegularExpression has 5 methods grouped under “Searching Strings Using Regular Expressions”. Methods such as:
It might also be useful to know about NSScanner, but this class would be more useful if you’re parsing the string than simply looking for sub-parts.