首页 > 代码库 > iOS nsstring 截取字符前后字符串

iOS nsstring 截取字符前后字符串

// Str = @"PEK_LHR"

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

from = [trafficeStr substringToIndex:range.location];

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

iOS nsstring 截取字符前后字符串