问题
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?
回答1:
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:@" " ]
来源:https://stackoverflow.com/questions/3767721/how-to-remove-a-particular-sign-from-a-string