Skip to content

Instantly share code, notes, and snippets.

@appyaaron
Last active December 26, 2015 15:49
Show Gist options
  • Save appyaaron/7175453 to your computer and use it in GitHub Desktop.
Save appyaaron/7175453 to your computer and use it in GitHub Desktop.
A nice and simple way to get the characters in-between a start character and an end character using NSRange. Replace cell.text with your string.
NSString *param3 = nil;
NSRange start3 = [cell.text rangeOfString:@"thestartcharacterhere"];
if (start3.location != NSNotFound)
{
param3 = [cell.text substringFromIndex:start3.location + start3.length];
NSRange end3 = [param3 rangeOfString:@"theendcharacterhere"];
if (end3.location != NSNotFound)
{
param3 = [param3 substringToIndex:end3.location];
}
NSLog(@"%@", param3);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment