开发者

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

开发者 https://www.devze.com 2023-02-28 06:39 出处:网络
I knew a instance method of NSString. - (NSRange)rangeOfString:(NSString *)aString My source string looks like this: \"abcdEFGhi\"

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

精彩评论

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