我要删除分隔符并分隔它们之间的所有单词?我该怎么办?解决方案 分割字符串: NSArray * parts = [string componentsSeparatedByString:@〜"]; 从数组中组装一个字符串: NSString * string = [parts componentsJoinedByString:@"]; 通过使用空格替换所有出现在〜中的字符串来对字符串进行消毒: NSString * string = [string stringByReplacingOccurrencesOfString:@〜" \withString:@"] i have a string gpbusd~buy~~~~update~HIT 40 PIPS~HIT 110 PIPS~~gpbusd~buy~~~BREAK EVEN~update~HIT~100+~~gpbusd~buy~1.5500/25~1.5455~~new~40~100+~~gpbusd~buy~~~~update~CLOSE 0 TO 10 PIPS N~~~gpbusd~buy~1.5335/50~1.5320~~new~40~80+~~gpbusd~buy~~~~update~~15-20 PIPS CLOSE~KEEP OPEN~gpbusd~buy~1.5530/50~~1.5505~update~HIT~80~KEEP OPEN~gpbusd~buy~1.5530/50~1.5465~~new~40~80~100+~gbpjpy~sell~131.05/.130.75~132.15~~new~60~100~keep open~eurusd~sell~1.2840/20~1.2870~STOP~update~~~~i want remove the delimeter sign and separate all the words between them ?how can i do it? 解决方案 Splitting a string:NSArray *parts = [string componentsSeparatedByString: @"~"];Assembling a string from an array:NSString *string = [parts componentsJoinedByString: @" "];Sanitizing a string, by replacing all occurences of ~ with whitespace:NSString *string = [string stringByReplacingOccurrencesOfString: @"~"\ withString:@" " ] 这篇关于如何从字符串中删除特定符号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-28 01:06