// 1.使用標準的c字串來建立oc字串
/*char *cstr = "this is a stirng";
nsstring *ocstr = [nsstring stringwithutf8string:cstr];
nslog(@"oc stirng:%@", ocstr);*/
// 2.比較字串是否相等
/*nsstring *str1 = @"this is a string";
nsstring *str2 = @"this is a string";
bool result = [str1 isequal:str2];
nslog(@"result:%d", result);*/
// 3.比較字串的大小
/*nsstring *str1 = @"this is a string";
nsstring *str2 = @"this is a oc string";
bool result = [str1 compare:str2];
// result 是3種結果之一:nsorderedsame;nsorderedascending;nsordereddescending;
nslog(@"result:%d", result);*/
// 4.不考慮字串大小寫比較
/*nsstring *str1 = @"this is a string";
nsstring *str2 = @"this is a string";
bool result = [str1 caseinsensitivecompare:str2];
// result 是3種結果之一:nsorderedsame;nsorderedascending;nsordereddescending;
nslog(@"result:%d", result);*/
// 5.查詢子字串
/*nsstring *str1 = @"this is a string";
nsstring *str2 = @"string";
nsrange range = [str1 rangeofstring:str2];
nslog(@"range.location:%d, range.length%d", range.location, range.length);*/
// 6.從開頭擷取字串到指定的位置(不包含最後指定位置的字元)
/*nsstring *str1 = @"this is a string";
nsstring *str2 = [str1 substringtoindex:3];
// 指定位置的索引值不能大於字串str1的長度
nslog(@"str2:%@", str2);*/
// 7.從指定的位置擷取字串到末尾
/*nsstring *str1 = @"this is a string";
nsstring *str2 = [str1 substringfromindex:3];
// 指定位置的索引值不能大於字串str1的長度
nslog(@"%@", str2);*/
// 8.擷取任意字串(由開始位置和長度決定)
/*nsstring *str1 = @"this is a string";
nsstring *str2 = [str1 substringwithrange:nsmakerange(1, 3)];
nslog(@"str2:%@", str2);
*/// 9.判斷乙個字串是否是以另乙個字串開頭
/*nsstring *str1 = @"this is a string";
nsstring *str2 = @"this";
bool result = [str1 hasprefix:str2];
nslog(@"result:%d", result);
*/// 10.// 9.判斷乙個字串是否是以另乙個字串結尾
/*nsstring *str1 = @"this is a string";
nsstring *str2 = @"string";
bool result = [str1 hassuffix:str2];
nslog(@"result:%d", result);*/
// 11.分割字串
/*nsstring *str1 = @"this is a string";
nsarray *array = [str1 componentsseparatedbystring:@" "];
nslog(@"array:%@", array);
*/// 12.
/*nsstring *str = @"this is a string";
nsarray *array = [str componentsseparatedbycharactersinset:[nscharacterset whitespacecharacterset]];
nslog(@"array:%@", array);*/
// 13.組合字串
/*nsarray *array = @[@"this", @"is", @"a", @"string"];
nsstring *str1 = [array componentsjoinedbystring:@" "];
nslog(@"str1:%@", str1);*/
// 14.其他關於路徑的功能(字串關於路徑的操作可以參考相關的函式)
/*nsstring *str1 = @"root/temp/test";
nslog(@"str:%@", str2);
*/
mysql常用字串 MYSQL常用字串函式寶典
mysql常用字串函式 想更進一步加強自己在查詢語句方面的能力,需要掌握常用函式。字串函式 1 concat s1,s2,sn 將s1,s2,sn串聯成乙個字串。exp root test 14 43 desc t1 field type null key default extra id int ...
C 常用字串操作
獲得漢字的區位碼 byte array new byte 2 array system.text.encoding.default.getbytes 啊 int i1 short array 0 0 int i2 short array 1 0 unicode解碼方式下的漢字碼 array syst...
常用字串操作函式
1 字串copy函式strcpy,實現如下 include char mystrcpy char dest,const char sor 將源字元sor串拷到目的字串dest return ret 2 判斷乙個字串中的子字串strstr,實現如下 include include char mystr...