美文网首页
NSStringCompareOptions

NSStringCompareOptions

作者: 夏天的风_song | 来源:发表于2017-06-05 15:28 被阅读0次

NSStringCompareOptions
多个字符串类的搜索和比较方法的可用选项

typedef NS_OPTIONS(NSUInteger, NSStringCompareOptions) {
    NSCaseInsensitiveSearch = 1,//不区分大小写的搜索
    NSLiteralSearch = 2,        /* 精确的逐个字符串等价。Exact character-by-character equivalence */
    NSBackwardsSearch = 4,      /*从源字符串的末尾搜索、 Search from end of source string */
    NSAnchoredSearch = 8,       /*搜索仅限于开始(或结束,如果是从末尾开始的搜索)源字符串 Search is limited to start (or end, if NSBackwardsSearch) of source string */
    NSNumericSearch = 64,       /*。用字符串中的数字的值进行比较, 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, /*搜索忽略变音符号。 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, /* 如果字符串是等效的但不是严格相等的,比较会被强制返回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兼容的正则表达式。如果设置了这个选项,那么其余选项除了NSCaseInsensitiveSearchNSAnchoredSearch,别的都不能使用

相关文章

网友评论

      本文标题:NSStringCompareOptions

      本文链接:https://www.haomeiwen.com/subject/goiifxtx.html