我试图找到如何从“ /games/usa/2013-05-01/game1.html ”中提取“ 2013-05-01/game1 ”,但我不知道该怎么做。我已经尝试了一些正则表达式,但它没有用。而且我也不知道这是否是最好的方法。这是我到目前为止所尝试的。
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"/[0-9]{4}-[0-9]{2}-[0-9]-{2}\//\.*$)" options:NSRegularExpressionCaseInsensitive error:NULL];
NSTextCheckingResult *newSearchString = [regex firstMatchInString:opening_time options:0 range:NSMakeRange(0, [opening_time length])];
NSString *substr = [opening_time substringWithRange:newSearchString.range];
NSLog(@"%@", substr);
任何帮助,将不胜感激。