我正在尝试从字符串中获取 SubString
这是我正在调用的方法
-(NSString *)subStringBetweenStrings:(NSString*)str open:(NSString*)open close:(NSString *)close
{
if ( str == nil || open == nil || close == nil )
return nil;
int start = [str rangeOfString:open].location;
if (start != -1)
{
int end = [str rangeOfString:close].location;
if ( end != -1)
{
return [str substringFromIndex:start]; // DONT WANT
}
}
return nil;
}
我有start point
,我有End point
。如何从开始和结束索引中获取子字符串,例如 return[ str subStringWithRange:(start, end)];