How to replace a character in NSString without inserting a space?

Posted by Sheehan Alam on Stack Overflow See other posts from Stack Overflow or by Sheehan Alam
Published on 2010-04-05T23:47:13Z Indexed on 2010/04/05 23:53 UTC
Read the original article Hit count: 151

Let's assume I have the string

NSString* myString  = @"Hello,";

How can I remove the comma without leaving a space? I have tried:

NSString* newString = [myString stringByReplacingOccurrencesOfString:@"," withString:@""];

and

NSString* newString = [myString stringByTrimmingCharactersInSet:[NSCharacterSet punctuationCharacterSet]];

But both are leaving spaces.

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about iphone