我正在使用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 output 1= "1234567891012“或者输出2可以类似于"+1234567891012
发布于 2012-01-25 13:29:22
试试这个:
NSString * forAlphaNumeric = @"^([+]{1})(a-zA-Z0-9{13})$";
BOOL isMatch = [yourString isMatchedByRegex:forAlphaNumeric];
NSString * forNumeric = @"^([+]{1})(0-9{13})$";
BOOL isMatch = [yourString isMatchedByRegex:forNumeric];https://stackoverflow.com/questions/8998089
复制相似问题