NSString空格符转换行符 连续空格取一次

NSString *replaceString = [contentStr stringByReplacingOccurrencesOfString:@" " withString:@"\n"];      
     replaceString = [replaceString stringByReplacingOccurrencesOfString:@"," withString:@"\n"];   
     NSRegularExpression *regular; 
     regular = [[NSRegularExpression alloc] initWithPattern:@"\n{1,}"     
                                                    options:NSRegularExpressionCaseInsensitive    
                                                      error:nil];


               
 replaceString = [regular stringByReplacingMatchesInString:replaceString 
                                                   options:NSRegularExpressionCaseInsensitive  
                                                     range:NSMakeRange(0, [replaceString length]) 
                                              withTemplate:@"\n"];

你可能感兴趣的:(NSString空格符转换行符 连续空格取一次)