[英]How to use RegexKitLite correctly
我正在使用RegexKitLite,我想驗證我的uitextfield是否帶有+前綴,並且包含13個數字長度或僅13個數字值。
請告訴我
下面是我嘗試的代碼
textview.text = @"123458kdkmfmdfmsdf"
NSString *regEx = @"{3}-[0-9]{3}-[0-9]{4}";
NSString *match = [textView.text stringByMatching:regEx];
if ([match isEqual:@""] == NO)
{ NSLog(@"Phone number is %@", match); }
else { NSLog(@"Not found."); }
我想要的輸出是belo ouput 1 =“ 1234567891012”或輸出2可以像“ +1234567891012
嘗試這個 :
NSString * forAlphaNumeric = @"^([+]{1})(a-zA-Z0-9{13})$";
BOOL isMatch = [yourString isMatchedByRegex:forAlphaNumeric];
NSString * forNumeric = @"^([+]{1})(0-9{13})$";
BOOL isMatch = [yourString isMatchedByRegex:forNumeric];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.