Ios is case-insensitive and ios is case-insensitive.
- NSString * str;
- // Use stringWithFormat to generate a formatted string
- Str = [NSString stringWithFormat: @ "This is % @", "John"];
- NSLog (@ "str ---> % @", str );
- // String length;
- NSLog (@ "The length of this string is % @", [str length]);
- // When the string is compared with isbench tostring, NO (false) is returned, and isbench tostring is case sensitive.
- BOOL isequal = [str isw.tostring: @ "this is John"];
- // String sequence comparison column compare, and the returned result is NSComparisonResult
- // Type enum _ NSComparisonResult {
- // NSOrderedAscending =-1,
- // NSOrderedSame,
- // NSOrderedDescending
- //}
- Int result = [@ "bool" compare: @ "cool"];
- NSLog (@ "The result is % d", result );
- // Compare comparison Rules options
- // NSLiteralSearch case sensitive (full comparison)
- // NSCaseInsensitiveSearch is case insensitive
- // NSNumericSearch only compares the number of strings, not the String Literal Value
- Int result1 = [@ "This is John" compare: @ "this is John" options: NSCaseInsensitiveSearch | NSNumericSearch];
- NSLog (@ "The result is % d", result1 );
- // Whether the start of the string contains another string hasPrefix. The returned result is YES (true)
- BOOL isHas = [str hasPrefix: @ "This"];
- // Whether the end of the string contains another string hasSuffix. The returned result is YES (true)
- BOOL isHas = [str hasSuffix: @ "John"];
- // Find the position of the string in another string
- Nsange range = [str rangeOfString: @ "is" options: NSCaseInsensitiveSearch];
- NSLog (@ "The location in the string named 'str' of 'is' @ d", range. location );