String split array

Does not contain a separator
NSString * str = @"hello";
NSMutableArray * arr = [NSMutableArray arrayWithCapacity:0];
         // Traverse the string and traverse it by character. Each character will be passed out through the substring in the block parameter.
    [str enumerateSubstringsInRange:NSMakeRange(0, str.length) options:NSStringEnumerationByComposedCharacterSequences usingBlock:^(NSString *substring, NSRange substringRange, NSRange enclosingRange, BOOL *stop) {
        [arr addObject:substring];     
    }];
NSLog(@"arr = %@", arr);
 Separator
 NSArray *array = [str componentsSeparatedByString:@","];--separator
 Convert array array to string
 NSString *str = [array componentsJoinedByString:@","]; , separator

Intelligent Recommendation

C ++ string char [] array split Split

STRTOK provided by C ++ for string array segmentation, don't say, on the code: Output results:...

More Recommendation

SQL Server string to array (split)

1, dynamic SQL method 2, the cycle interception method Reprinted at: https://www.jianshu.com/p/2825b4f9bd39...

String split switch array StringUtils

We often encounter in their daily development will be divided in accordance with a specified string of characters. At this time, we tend to think of usestr.split(","), Obtained by processing...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top