我已經編寫了驗證美國郵政編碼的代碼......但它給了我錯誤,未知的轉義序列\ d在驗證字符串中。 代碼:定義驗證字符串時出錯
- (BOOL)zipcodevalidation:(NSString *)zipstring {
NSString *emailRegex = @"(^\d{5}(-\d{4})?$)";
NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex];
return [emailTest evaluateWithObject:zipstring];
}
當我輸入00000。根據這個驗證碼是否有效? – vivek