" (2.1\x26#160;mi / 7 分钟)"
我有上面的字符串,我只需要到达距离和时间。我将如何使用 RegexKitLite 脚本执行此操作?理想情况下,以下是我正在寻找的内容:
时间 = 7 分钟距离 = 2.1 英里
谢谢
" (2.1\x26#160;mi / 7 分钟)"
我有上面的字符串,我只需要到达距离和时间。我将如何使用 RegexKitLite 脚本执行此操作?理想情况下,以下是我正在寻找的内容:
时间 = 7 分钟距离 = 2.1 英里
谢谢
不是使用 RegexKitLite 脚本,但我是这样做的:
NSString* tooltipHtml = [apiResponse stringByMatching:@"tooltipHtml:\\"([^\\"]*)\\"" capture:1L];
NSLog(@"tooltip Html: %@", tooltipHtml);
int leftParanthesis = [tooltipHtml rangeOfString:@"("].location;
int inverseSlash = [tooltipHtml rangeOfString:@"\\"].location;
int slash = [tooltipHtml rangeOfString:@"/"].location;
int semiColumn = [tooltipHtml rangeOfString:@";"].location;
int rightParanthesis = [tooltipHtml rangeOfString:@")"].location;
NSRange distanceRange = NSMakeRange(leftParanthesis+1, inverseSlash-leftParanthesis-1);
NSString *distance = [tooltipHtml substringWithRange:distanceRange];
NSRange distanceTypeRange = NSMakeRange(semiColumn+1, slash-semiColumn-1);
NSString *distanceType = [tooltipHtml substringWithRange:distanceTypeRange];
NSRange timeRange = NSMakeRange(slash+1, rightParanthesis-slash-1);
NSString *time = [tooltipHtml substringWithRange:timeRange];
NSString *distanceCompact = [distance stringByAppendingString:distanceType];
NSLog(@"Distance %@:", distance);
NSLog(@"Distance type %@:", distanceType);
NSLog(@"Time %@:", time);
NSLog(@"distance Compact %@:", distanceCompact);