Objective-C: I want to remove all zeros which trail and lead with some exceptions. For example:
0.05000 -> 0.05
000.2300 -> 0.23
005.0 -> 5
500.0 -> 500
60.0000 -> 60
56.200000 -> 56.2
56.04000 -> 56.04
What I tried is something like this [.0]+$|(^0+)
. But it doesn't help what I'm trying to achieve. I am using NSString with RegularExpressionSearch as follows:
NSString *cleaned = [someString stringByReplacingOccurrencesOfString:@"[.0]+$|(^0+)"
withString:@""
options:NSRegularExpressionSearch
range:NSMakeRange(0, self.doseTextField.text.length)];
Any help would be appreciated.