标签:int head span logs nsstring 定位 div code ring
NSString *str = @"<head>小码哥</head>"; str = [str substringFromIndex:7]; NSLog(@"str = %@", str); 输出结果: 小码哥</head>
从字符串的开头一直截取到指定的位置to,但不包括该位置的字符
NSString *str = @"<head>小码哥</head>"; str = [str substringToIndex:10]; NSLog(@"str = %@", str); 输出结果: <head>小码哥
按照所给出的NSRange从字符串中截取子串
NSString *str = @"<head>小码哥</head>"; NSRange range; /* range.location = 6; range.length = 3; */ range.location = [str rangeOfString:@">"].location + 1; range.length = [str rangeOfString:@"</"].location - range.location; NSString *res = [str substringWithRange:range]; NSLog(@"res = %@", res); 输出结果: 小码哥
标签:int head span logs nsstring 定位 div code ring
原文地址:http://www.cnblogs.com/xufengyuan/p/6623867.html