/*
<span style="white-space:pre"> </span>1>多个数据拼接成一个字符串
2>字符串的末尾追加新的字符
3>在指定的范围插入字符串
4>使用新的字符替换原有的字符
5>在字符串中删除特定的某些字符
6>去掉字符串中的空格
*/
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
int year = 2015;
int month = 07;
int day = 20;
NSString * address = @"北京市";
NSString * dateAndAddress = [[NSString alloc] initWithFormat:@"%d年%d月%d日 地址:%@",year,month,day,address];
NSLog(@"%@",dateAndAddress);
NSString * str2 = @"qianfeng";
// qianfeng.com
NSString *str3 = [str2 stringByAppendingString:@".com"];
NSLog(@"str3 %@ str2 %@",str3,str2);
NSString * str4 = @"www..com";
// www.baidu.com
NSRange range = {3,2};
NSString * str5 = [str4 stringByReplacingCharactersInRange:range withString:@"-baidu-"];
NSLog(@"str5 %@",str5);
NSString * str6 = @"www.baidu.com";
NSString * str7 = [str6 stringByReplacingOccurrencesOfString:@"." withString:@"-"];
NSLog(@"str7 %@",str7);
//5>在字符串中删除特定的某些字符
NSString * str8 = @"www..baidu..com";
NSString * str9 = [str8 stringByReplacingOccurrencesOfString:@"." withString:@""];
NSLog(@"str9 %@ str8 %@",str9,str8);
NSString * str10 = @"www baidu com";
NSString * str11 = [str10 stringByReplacingOccurrencesOfString:@" " withString:@""];
NSLog(@"str11 %@",str11);
}
return 0;
}