1將字符串分割成數組數組
NSString *a = [[NSString alloc] initWithString : @"0755-12424432;137424744;42434223" ];spa
NSArray *b = [a componentsSeparatedByString:@";"];component
2截取字符串orm
NSString *str = @"0755-12424432;137424744;42434223";ci
NSRange rang = [str.tel rangeOfString:@";"];字符串
if (rang.location != NSNotFound) {string
phoneStr = [str substringWithRange:NSMakeRange(0, rang.location)];it
NSLog(@"rang.location%@",phoneArr);io
}方法
3字符串替換
NSString *str = [yourstr stringByReplacingOccurrencesOfString:@"<br>" withString:@"\n"];
4判斷某字符串是否包含某字符或者字符串,可使用如下方法
if ([str1 rangeOfString:str].location != NSNotFound) {
NSLog(@"這個字符串中有str");
}