开发者

Replace string within a array

    NSArray *ArtistNames = [RawData componentsMatchedByRegex:regEx1]; 
    NSCharacterSet *doNotWant = [NSCharacterSet characterSetWithCharactersInString:@"'"];
    ArtistNames = [[ArtistNames co开发者_StackOverflow社区mponentsSeparatedByCharactersInSet: doNotWant] componentsJoinedByString: @"'"];

Thats my code at the moment basically i cannot use it as ArtistNames is a array not a string, how would i get past this ?


I think you're calling your methods in the wrong order. Try breaking it into multiple statements.

// The separator should be some string of characters guaranteed to not be in any of the strings in the array.
#define SEPARATOR @"---***---"

NSArray *artistNames = [RawData componentsMatchedByRegex:regEx1]; 
NSString *doNotWant = @"'"
NSString *combinedNames = [artistNames componentsJoinedByString:SEPARATOR];
combinedNames = [combinedNames stringByReplacingOccurrencesOfString:doNotWant withString:@""];
artistNames = [combinedNames componentsSeparatedByString:SEPARATOR];


Why not just loop over the array and create the second array yourself?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜