Skip to content

Instantly share code, notes, and snippets.

@hfossli hfossli/code
Last active Sep 23, 2015

Embed
What would you like to do?
{
NSString *string = @"123-456-7890";
NSArray *components = [string componentsSeparatedByString:@"-"];
NSLog(@"Components: (%i) %@", (int)components.count, components);
}
{
NSString *string = @"-123-456-7890";
NSArray *components = [string componentsSeparatedByString:@"-"];
NSLog(@"Components: (%i) %@", (int)components.count, components);
}
{
NSString *string = @"-123-456-7890-";
NSArray *components = [string componentsSeparatedByString:@"-"];
NSLog(@"Components: (%i) %@", (int)components.count, components);
}
{
NSString *string = @"-123---456-7890-";
NSArray *components = [string componentsSeparatedByString:@"-"];
NSLog(@"Components: (%i) %@", (int)components.count, components);
}
Components: (3) (
123,
456,
7890
)
Components: (4) (
"",
123,
456,
7890
)
Components: (5) (
"",
123,
456,
7890,
""
)
Components: (6) (
"",
123,
"",
456,
7890,
""
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.