请告诉我如何从由某个字符分隔的单个字符串中提取子字符串?
/ 2132321321/34 3/0 /
感谢
答案 0 :(得分:4)
您可以通过执行...
将字符串分隔为数组NSString *myString = @"/ 2132321321/34 3/0 /";
NSArray *strings = [myString componentsSeparatedByString:@"/"];
这将包含所有字符串的数组,如...
[@" 2132321321",
@"34 3",
@"0 "];
然后你可以......
for (NSString *string in strings) {
NSLog(@"%i", [string length]);
// You can do what you want in here.
}
这将打印所有长度。