.es(metric=cardinality:geoip.ip)
在字符串上方,我需要获得两个单独的字符串,就像后面一样。
NSString *mystring = @"123 This is testing message";
有没有快速的方法从NSString *one = @"123";
NSString *Two = @"This is testing message";
检索两个单独的字符串?
答案 0 :(得分:0)
您可以使用此
- (NSString *)extractNumberFromText:(NSString *)text
{
NSCharacterSet *nonDigitCharacterSet = [[NSCharacterSet decimalDigitCharacterSet] invertedSet];
return [[text componentsSeparatedByCharactersInSet:nonDigitCharacterSet] componentsJoinedByString:@""];
}
致电
NSString * str = @"123 This is testing message";
NSString *number = [self extractNumberFromText:str];
NSString *text = [str substringFromIndex:number.length+1];