我有一个这样的字符串:“/ Myapp / auth / hrHeadcount + ME + All IOU + Headcount + Grade”我想在另一个字符串中只保存“ HeadCount ”。我怎么能这样做?
答案 0 :(得分:1)
NSString *srcStr = @"/Myapp/auth/hrHeadcount+ME+All IOU+Headcount+Grade";
NSString *dstStr = [[srcStr componentsSeparatedByString:@"+"] objectAtIndex:3];
答案 1 :(得分:0)
如果您确定它具有相同的格式,那么您可以执行以下操作
NSString *string1 = @"/Myapp/auth/hrHeadcount+ME+All IOU+Headcount+Grade";
NSArray *stringArray = [string1 componentsSeparatedByString:@"/"];
NSString *string2 = stringArray[3];
NSArray *finalArray = [string2 componentsSeparatedByString:@"+"];
NSString *finalString = finalArray[0];
final String将具有headCount u require