Hi, is there a simple way to remove the extra spaces in a string? ie like...
NSString *str = @"this string has extra empty spaces";
result should be:
NSString *str = @"this string has extra empty spaces";
Thanks!
Hi, is there a simple way to remove the extra spaces in a string? ie like...
NSString *str = @"this string has extra empty spaces";
result should be:
NSString *str = @"this string has extra empty spaces";
Thanks!
replace all double space with a single space until there are no more double spaces in your string.
- (NSString *)stripDoubleSpaceFrom:(NSString *)str {
while ([str rangeOfString:@" "].location != NSNotFound) {
str = [str stringByReplacingOccurrencesOfString:@" " withString:@" "];
}
return str;
}