Iphone 如何正确使用RegexKitLite
我使用的是RegexKitLite,我想验证我的uitextfield是否有+前缀,是否包含13个数字长度或仅包含13个数字值 请让我知道 下面是我试过的代码Iphone 如何正确使用RegexKitLite,iphone,regex,ios4,Iphone,Regex,Ios4,我使用的是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:@""] ==
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."); }
我想要的输出是贝洛
输出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];
您想只添加13个数值还是任何数值?请给我您想要的输出