I knew a instance method of NSString.
- (NSRange)rangeOfString:(NSString *)aString
My source string looks like this: "abcdEFGhi"
When I use [srcStr.rangeOfString:@"efg"];, there is no substring was found.
How can I solve this problem?
There is one more version of rangeOfString method you could use that.
- (NSRange)rangeOfString:(NSString *)aString options:(NSStringCompareOptions)mask
So use as below
[srcStr rangeOfString:@"efg" options:NSCaseInsensitiveSearch];
I think you're looking for:
[srcStr rangeOfString:@"efg" options:NSCaseInsensitiveSearch];
来源:https://stackoverflow.com/questions/5739071/how-to-search-a-substring-from-a-nsstring-with-case-insensitive