Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 is no substring was found.

How can I solve this problem?

like image 972
Daemon Avatar asked Apr 21 '11 03:04

Daemon


2 Answers

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]; 
like image 51
Jhaliya - Praveen Sharma Avatar answered Sep 27 '22 22:09

Jhaliya - Praveen Sharma


I think you're looking for:

[srcStr rangeOfString:@"efg" options:NSCaseInsensitiveSearch]; 
like image 45
Sam Avatar answered Sep 27 '22 23:09

Sam