gpt4 book ai didi

iphone - 替换数组中的字符串

转载 作者:行者123 更新时间:2023-12-03 17:28:41 24 4
gpt4 key购买 nike

    NSArray *ArtistNames = [RawData componentsMatchedByRegex:regEx1]; 
NSCharacterSet *doNotWant = [NSCharacterSet characterSetWithCharactersInString:@"'"];
ArtistNames = [[ArtistNames componentsSeparatedByCharactersInSet: doNotWant] componentsJoinedByString: @"'"];

这就是我目前的代码,基本上我无法使用它,因为 ArtistNames 是一个数组而不是字符串,我将如何克服这个问题?

最佳答案

我认为您以错误的顺序调用方法。尝试将其分成多个语句。

// 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];

关于iphone - 替换数组中的字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3807087/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com