This will remove white space and newline from both ends of a string:
NSString *newString = [oldString stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceCharacterSet]];
NSString *newString = [oldString stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]];
This will remove white space and newline from any where in string:
//give %20 on space
NSString *string = [[NSString alloc]initWithFormat:@"%@",[yourString stringByReplacingOccurrencesOfString:@" " withString:@"%20" options:NSRegularExpressionSearch range:NSMakeRange(0, yourString.length)]];
No comments:
Post a Comment