Telephone number format should be international,Is there any Regex for phone number validation in iPhone

我是研究僧i 提交于 2019-12-30 07:50:06

问题


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.


回答1:


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]$";


来源:https://stackoverflow.com/questions/4301363/telephone-number-format-should-be-international-is-there-any-regex-for-phone-num

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!