/**
* 去除字符串中连续换行,只保留结尾处换行
* allStr 字符串
* return 去除连续换行后的字符串
*/
+ (NSString *)trimAllNewline:(NSString *)allStr {
NSRegularExpression *regular = [[NSRegularExpression alloc] initWithPattern:@"\n{1,}" options:0 error:nil];
NSString *newString = [regular stringByReplacingMatchesInString:allStr options:0 range:NSMakeRange(0, [allStr length]) withTemplate:@"\n"];
return newString;
}
网友评论