How to get substring of NSString?
If I want to get a value from the NSString @"value:hello World:value" , what should I use? The return value I want is @"hello World" . Regexident Option 1: NSString *haystack = @"value:hello World:value"; NSString *haystackPrefix = @"value:"; NSString *haystackSuffix = @":value"; NSRange needleRange = NSMakeRange(haystackPrefix.length, haystack.length - haystackPrefix.length - haystackSuffix.length); NSString *needle = [haystack substringWithRange:needleRange]; NSLog(@"needle: %@", needle); // -> "hello World" Option 2: NSRegularExpression *regex = [NSRegularExpression