Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Objective-C, rangeOfString from an offset

is it possible to use the method rangeOfString to search for a NSString starting from a given offset?

Something more similar to the strpos function in PHP.

Thanks

like image 284
Mark Avatar asked Dec 09 '22 09:12

Mark


1 Answers

Not -rangeOfString:, but a similar method - -rangeOfString:options:range:.

(Edit: An example)

NSString *string = @"YaddaYaddaYadda";
NSString *searchString = @"Yadda";
NSRange thisCharRange, searchCharRange;

searchCharRange = NSMakeRange(3, [string length]);
thisCharRange = [string rangeOfString:searchString options:0 range:searchCharRange];
NSLog(@"thisCharRange: %@", NSStringFromRange(thisCharRange));
like image 72
Sherm Pendley Avatar answered Dec 30 '22 10:12

Sherm Pendley