如何正确使用RegexKitLite
我正在使用 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 输出 1 =“1234567891012” 或者输出 2 可以类似于“+1234567891012
I am using RegexKitLite, i want to validate that my uitextfield has + prefixed and contains numeric length of 13 or only 13 numeric values.
Please let me know
Below is the code i tried
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."); }
the ouput i want is belo
ouput 1 = "1234567891012"
or output 2 can be like "+1234567891012
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
试试这个:
try this :