iOS nsstring 截取字符前后字符串

// Str = @"PEK_LHR"

NSRange range = [trafficeStr rangeOfString:@"_" options:NSBackwardsSearch];

from = [trafficeStr substringToIndex:range.location];

to = [trafficeStr substringFromIndex:range.location + 1];

你可能感兴趣的:(NSString)