How to find and replace symbols in a string?

后端 未结 3 1571
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-16 19:06

I know it must be a very simple thing to do but I\'ve never had to treat strings before (in Objective-C) and apparently there\'s not RegEx on Cocoa-Touch.

Well, the

3条回答
  •  走了就别回头了
    2021-01-16 19:26

    you can try this:

    NSString *s = @"12.827#@584";
    NSCharacterSet *removeCharSet = [NSCharacterSet characterSetWithCharactersInString:@"/:@#"];
    s = [[s componentsSeparatedByCharactersInSet: removeCharSet] componentsJoinedByString: @""];
    NSLog(@"%@", s);
    

提交回复
热议问题