开发者

Need to remove string which in between the braces

I need to Remove some extra string that which coming in between the "(" ")" is this possible?. If so kindly tell me the way that need to do.

For example "Lead Programmer Ana开发者_开发问答lyst(#5641)". I need to remove the string #5641 that which is between ( and ).

Thank you, S.


pass Your string to the below method , it will return the proper string

- (NSString *)stringCleaner:(NSString *)yourString {

        NSScanner *theScanner;
        NSString *text = nil;

        theScanner = [NSScanner scannerWithString:yourString];

        while ([theScanner isAtEnd] == NO) {

        [theScanner scanUpToString:@"(" intoString:NULL] ; 

            [theScanner scanUpToString:@")" intoString:&text] ;

        yourString = [yourString stringByReplacingOccurrencesOfString:
                    [NSString stringWithFormat:@"%@)", text]
                                                   withString:@""];

        } 

        return yourString;

    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜