This should be simple but it's not working. I am trying to strip single quote marks from an NSString named parms using the following (stripped of non-relevant vars in the format string):
NSString *newVar =[[NSString alloc] initWithFormat:@"%@", [parms stringByReplacingOccurrencesOfString:@"'" withString:@""]];
So if parms contains "Mike's Hat" I would expect that newVar would contain "Mikes Hat". Instead it contains "Mike's Hat".
There must be more to your code than you are proving, but the following works perfectly:
NSString *parms = @"Mike's Hat";
NSString *newVar =[parms stringByReplacingOccurrencesOfString:@"’" withString:@""];
NSLog(@"%@",newVar);
Output: Mikes Hat
There could be a possibility that the character '
may not be the same character in your parms string if the above does not work for you.
Turns out, you are using the wrong character copy/paste this character into your string: ’
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With