我需要驗證用戶在我的應用中登錄時使用的用戶名。例如:用簡單的方法驗證iOS上的用戶名
彼得$ @是無效的,但 peter123有效
如果用戶名包含#$%&「* + -/=^_`{|}〜@ ,;!?在他的名字,alertView應該出現通知用戶
我必須比較這樣的字符串嗎?
-(BOOL) checkIfUsernameValidation{
NSString *_username = playerName.text;
NSString *expression = @".!#$%&'*+-/=?^_`{|}[email protected],;";
if(![_username compare:expression]){
return YES;
}
else
return NO;
}
感謝
也許這線程將幫助http://stackoverflow.com/questions/16866879/string-contains-letters – Arbitur