- #import <stdio.h>
- NSString * stringWithoutNum(NSString *str)
- {
- NSMutableString *s = [NSMutableString string];
- for (int i = 0; i<str.length; i++) {
- char c = [str characterAtIndex:i];
-
-
- if (c<'0' || c>'9')
- {
- [s appendFormat:@"%c", c];
- }
- }
-
- return s;
- }
- int main()
- {
- @autoreleasepool {
-
-
- NSString *str = @"sdsa1[]agjoiew41faf132";
-
-
- NSString *newStr = stringWithoutNum(str);
-
- NSLog(@"%@", newStr);
- }
- }
复制代码 |