开发者

How to search a subString from a NSString with case-insensitive

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开发者_StackOverflow 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];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜