String reassembly, string insertion, substitution, deletion, stitching

Source: Internet
Author: User

/* <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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.