NSStringCompareOptions
多個(gè)字符串類的搜索和比較方法的可用選項(xiàng)
typedef NS_OPTIONS(NSUInteger, NSStringCompareOptions) {
NSCaseInsensitiveSearch = 1,//不區(qū)分大小寫的搜索
NSLiteralSearch = 2, /* 精確的逐個(gè)字符串等價(jià)。Exact character-by-character equivalence */
NSBackwardsSearch = 4, /*從源字符串的末尾搜索、 Search from end of source string */
NSAnchoredSearch = 8, /*搜索僅限于開始(或結(jié)束,如果是從末尾開始的搜索)源字符串 Search is limited to start (or end, if NSBackwardsSearch) of source string */
NSNumericSearch = 64, /*。用字符串中的數(shù)字的值進(jìn)行比較, Added in 10.2; Numbers within strings are compared using numeric value, that is, Foo2.txt < Foo7.txt < Foo25.txt; only applies to compare methods, not find */
NSDiacriticInsensitiveSearch NS_ENUM_AVAILABLE(10_5, 2_0) = 128, /*搜索忽略變音符號(hào)。 If specified, ignores diacritics (o-umlaut == o) */
NSWidthInsensitiveSearch NS_ENUM_AVAILABLE(10_5, 2_0) = 256, /* 搜索忽略具有全寬和半寬形式的字符的寬度差異,例如在東亞字符串集。If specified, ignores width differences ('a' == UFF41) */
NSForcedOrderingSearch NS_ENUM_AVAILABLE(10_5, 2_0) = 512, /* 如果字符串是等效的但不是嚴(yán)格相等的,比較會(huì)被強(qiáng)制返回same,例如 "aaa"和"AAA"。If specified, comparisons are forced to return either NSOrderedAscending or NSOrderedDescending if the strings are equivalent but not strictly equal, for stability when sorting (e.g. "aaa" > "AAA" with NSCaseInsensitiveSearch specified) */
NSRegularExpressionSearch NS_ENUM_AVAILABLE(10_7, 3_2) = 1024 /* Applies to rangeOfString:..., stringByReplacingOccurrencesOfString:..., and replaceOccurrencesOfString:... methods only; the search string is treated as an ICU-compatible regular expression; if set, no other options can apply except NSCaseInsensitiveSearch and NSAnchoredSearch */
};
NSRegularExpressionSearch:只在
rangeOfString:...、stringByReplacingOccurrencesOfString:...和replaceOccurrencesOfString:...方法中適用。搜索字符串被視為與ICU兼容的正則表達(dá)式。如果設(shè)置了這個(gè)選項(xiàng),那么其余選項(xiàng)除了NSCaseInsensitiveSearch和NSAnchoredSearch,別的都不能使用