문자열에서 숫자만 추출하기
문자열에서 숫자만 추출하는 소스코드입니다.
NSString *str = @"sample/1234";
NSString *converStr = [[str componentsSeparatedByCharactersInSet:
[[NSCharacterSet characterSetWithCharactersInString:@"0123456789"] invertedSet]] componentsJoinedByString:@""];
NSLog(@" %@ ", converStr);
로그는 당연히
1234
가 출력됩니다
반응형
'IT > iOS' 카테고리의 다른 글
[iOS] 원 이미지 만들기 (0) | 2014.08.12 |
---|---|
UIButton title multi-line (0) | 2014.08.08 |
UILabel text size height (0) | 2014.08.05 |
프로젝트 개발과정 (0) | 2014.08.05 |
json 데이터에서 key, object 추출하기 (0) | 2014.08.01 |
NSMutableArray shuffle (배열 랜덤으로 섞기) (0) | 2014.07.23 |
tableview sectionheader 고정 막기 (0) | 2014.07.22 |
Current View get subview (0) | 2014.06.03 |