IOS marks all characters in a string of characters

Source: Internet
Author: User

    nsmutablestring * Mutstr = [nsmutablestring stringwithstring:@ "AAABBBBAAACCC"];    NSString * str = @ "a";    Nsrange range = {0,mutstr.length};    [Mutstr replaceoccurrencesofstring:@ "" withstring:@ "" Options:nsliteralsearch Range:range];        [Mutstr replaceoccurrencesofstring:@ "\ n" withstring:@ "" Options:nsliteralsearch Range:range];    nsmutableattributedstring * attr = [[nsmutableattributedstring alloc]initwithstring:mutstr];    Nserror * ERROR; Nsregularexpression * Express = [nsregularexpression regularexpressionwithpattern:str options:    Nsregularexpressioncaseinsensitive error:&error];    Nsarray<nstextcheckingresult *> * result = [Express matchesinstring:mutstr options:0 Range:range];        For (Nstextcheckingresult * match in result) {Nsrange range = [Match range];    [attr addattribute:nsforegroundcolorattributename Value:[uicolor Redcolor] range:range];    } UILabel * lbl = [[UILabel alloc]initwithframe:cgrectmake (100, 100, 200, 40)]; [SELf.view ADDSUBVIEW:LBL];    Lbl.textcolor = [Uicolor Bluecolor]; Lbl.attributedtext = attr;

  

IOS marks all characters in a string of characters

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.