电话号码格式应该是国际性的,在iPhone中是否有用于电话号码验证的正则表达式 [英] Telephone number format should be international,Is there any Regex for phone number validation in iPhone
本文介绍了电话号码格式应该是国际性的,在iPhone中是否有用于电话号码验证的正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
nofollow> RegexKitLite 。
至于正则表达式本身,像这样(来自
<$ p
^ \ +(?:[0-9]?){6,14} [0-9] $
请注意,当您在代码中指定它时,您需要转义反斜杠字符(\),所以它看起来像这样:
NSString * regexString = @^ \\ +(?:[0-9]?){6,14} [0-9] $;
Telephone number should be international and user has to enter the complete phone number with country code.
For that I need a regex for formatting the phone number.
解决方案
For real regex testing use RegexKitLite.
As for the regular expression itself, something like this (from Validate Phone Numbers: A Detailed Guide) should work:
^\+(?:[0-9] ?){6,14}[0-9]$
Note that when you specify it in your code you need to escape the backslash character (\), so it would look like this:
NSString *regexString = @"^\\+(?:[0-9] ?){6,14}[0-9]$";
这篇关于电话号码格式应该是国际性的,在iPhone中是否有用于电话号码验证的正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文