liwei's blog

字符串的操作

检查是否包含该字符串

1
2
3
4
5
6
7
8
NSString *temp = @"english, french, japanese, chinese";  
NSString *jap = @"japanese";
NSRange foundObj=[temp rangeOfString:jap options:NSCaseInsensitiveSearch];
if(foundObj.length>0) {
NSLog(@"Yes ! Jap found");
} else {
NSLog(@"Oops ! no jap");
}

从某一个字符串中的一个字符串开始截取

1
2
3
4
NSString *a =@"/pubic/evdaily.nsf/vwtrymaindocid/8E88469482579180035442A/$file/测试帐号及信息22.docx";  
NSRange range = [a rangeOfString:@"$file/"];//获取$file/的位置
NSString *b = [a substringFromIndex:(range.location+range.length)];//开始截取
NSLog(@"\n b: %@",b);