NSString *numberVector = @"( 1, 2, 3, 4)";
我想從這些數字中得到NSMutableArray ,能實現麼?
用下面的代碼實現
NSString *numberVector = @"(\n 1,\n 2,\n 3,\n 4\n)";
NSString *onlyNumbers = [numberVector stringByReplacingOccurrencesOfString:@"[^0-9,]" withString:@"" options:NSRegularExpressionSearch range:NSMakeRange(0, [numberVector length])];
NSArray *numbers=[onlyNumbers componentsSeparatedByString:@","];
NSLog(@"%@",numbers);