Contents

Views 961 Comment 0
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print

정규표현식으로 문자열 교체하는 예제

예) Kakao 계정에서 닉네임에 이모티콘 있을 시 제거하는 내용

NSString *pattern = @"[^\uAC00-\uD7A3xfe0-9a-zA-Z\\s]";
NSString *kakaoNickname = @"123 &1245; Hooni Test!!^^";

NSError *error = nil;
NSRegularExpression *regex =
    [NSRegularExpression regularExpressionWithPattern:pattern
        options:NSRegularExpressionCaseInsensitive error:&error];

NSString *modifiedString =
    [regex stringByReplacingMatchesInString:kakaoNickname options:0
        range:NSMakeRange(0, [kakaoNickname length]) withTemplate:@""];

NSLog(@"kakaoNickname : %@", modifiedString);



?

List of Articles
No. Category Subject Author Date Views
8 Develop [ios] 동영상 플레이어 샘플 (for Local File) file hooni 2017.02.07 1213
7 Develop [ios] 동영상 플레이어 샘플 (for Remote Url) file hooni 2017.02.07 1767
6 System/OS 무료로 HTTPS 적용하기 (Lets' Encrypt) file hooni 2017.02.16 2393
5 Develop [ios] Facebook Cache 갱신하는 함수 file hooni 2017.02.27 1330
4 Develop [ios] 동영상 플레이어 샘플 (for PIP Player) file hooni 2017.03.15 1410
» Develop [ios] NSString, RegularExpression Find/Replace hooni 2017.04.14 961
2 Develop [ios] Facebook SDK 로그인 설명 file hooni 2017.04.19 1361
1 Develop [ios] Requesting Location Permissions in iOS file hooni 2018.08.18 1742
Board Pagination Prev 1 2 3 Next
/ 3