/* <span style= "White-space:pre" ></span>1> multiple data stitching into a string 2> the end of the string appends a new character 3> inserts a string in the specified range 4> Replace the original character with the new character 5> remove certain characters from the string 6> the space in the string */#import <foundation/foundation.h>int main (int argc, const char * argv[]) {@autoreleasepool {int year = 2015; int month = 07; int day = 20; NSString * address = @ "Beijing"; NSString * dateandaddress = [[NSString alloc] initwithformat:@ "%d%d months%d days address:%@", year,month,day,address]; NSLog (@ "%@", dateandaddress); NSString * str2 = @ "Qianfeng"; qianfeng.com nsstring *STR3 = [str2 stringbyappendingstring:@ ". com"]; NSLog (@ "STR3%@ str2%@", STR3,STR2); NSString * STR4 = @ "www..com"; www.baidu.com Nsrange range = {3,2}; NSString * STR5 = [STR4 stringbyreplacingcharactersinrange:range withstring:@ "-baidu-"]; NSLog (@ "STR5%@", STR5); NSString * STR6 = @ "www.baidu.coM "; NSString * STR7 = [STR6 stringbyreplacingoccurrencesofstring:@ "." withstring:@ "-"]; NSLog (@ "Str7%@", STR7); 5> remove certain characters in the string NSString * str8 = @ "www..baidu..com"; NSString * STR9 = [str8 stringbyreplacingoccurrencesofstring:@ "." withstring:@ ""]; NSLog (@ "STR9%@ str8%@", str9,str8); NSString * str10 = @ "www baidu com"; NSString * Str11 = [Str10 stringbyreplacingoccurrencesofstring:@ "" withstring:@ ""]; NSLog (@ "Str11%@", Str11); } return 0;}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
String reassembly, string insertion, substitution, deletion, stitching