:P废话不多说,直接上代码
- #import <Foundation/Foundation.h>
- int main()
- {
- NSString *str = @"af323fs-fdsl j232-3lk-fldf224-998-fds232";
- NSMutableString *str2 = [[NSMutableString alloc] init];
-
- for (int i = 0; i<str.length; i++)
- {
- unichar c =[str characterAtIndex:i];
- NSString *s = [NSString stringWithFormat:@"%c", c];
-
- if (c > '0' && c < '9' )
- {
- [str2 appendString:s];
- }
- }
-
- NSLog(@"%@", str2);
- }
复制代码 |