So you're saying you have an NSString that starts with a number and ends with K or M? And you want to see what it consists of, and convert it to an actual numeric value? This is a job for NSScanner.
Though, to be quite honest, NSScanner was around long before regular expressions became available in Objective-C; nowadays I might just use NSRegularExpression.
Or, if you know for a fact that it really is a number followed by K or M, then you don't even have to do that. Just pull the last character off the end. That's the K or the M and you now know which it is. And what's left is a numeric string and you can just convert it to a number.
Pseudocode (not tested):
NSString* s = @"5.1M";
NSUInteger len = s.length;
NSString* numPart = [s substringToIndex: len-2];
NSString* unitPart = [s substringFromIndex: len-1];
int multiplier = 1000;
if ([unitPart isEqualToString: @"M"])
multiplier = 1000000;
float result = numPart.floatValue * multiplier;