电话号码格式应该是国际性的,在iPhone中是否有用于电话号码验证的正则表达式 [英] Telephone number format should be international,Is there any Regex for phone number validation in iPhone

查看:209
本文介绍了电话号码格式应该是国际性的,在iPhone中是否有用于电话号码验证的正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

电话号码应该是国际的,用户必须输入带有国家代码的完整电话号码。

为此我需要一个格式化电话号码的正则表达式。对于真正的正则表达式测试,使用

nofollow> RegexKitLite



至于正则表达式本身,像这样(来自

<$ p

$ 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆