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
you can try this:
NSString *s = @"12.827#@584";
NSCharacterSet *removeCharSet = [NSCharacterSet characterSetWithCharactersInString:@"/:@#"];
s = [[s componentsSeparatedByCharactersInSet: removeCharSet] componentsJoinedByString: @""];
NSLog(@"%@", s);
You do get regex in Cocoa Touch.
Here's a good discussion of the varying degrees of regex power in iOS, the blocks example at the end should get you most of the way there.
http://volonbolon.net/post/861427732/text-handling-in-ios-4
I understand you're trying to figure out the number included in the UITextFields's text
property and assign it to a float variable.
Try using an NSScanner for this:
NSScanner* textScanner = [NSScanner localizedScannerWithString:textfield.text];
float* floatValue;
[textScanner scanFloat:&floatValue];
floatValue now contains the parsed float value of your textfield.