正则表达式以验证电话号码 [英] Regular expression to validate phone number

查看:108
本文介绍了正则表达式以验证电话号码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要一个正则表达式验证这种格式的pnone数字任何帮助



961_(71或72或76或79或3)_和6位数[ 0-9]



例如:96171648262,9613635241



谢谢,

解决方案

尝试:

 961(71 | 72 | 76 | 79 | 3)\d {6} 









我如何在vb.net中使用它来验证字符串



  Dim 验证作为 正则表达式(  961(71 | 72 | 76 | 79 | 3)\d {6}
Dim inp 作为 字符串 = 96171648262
如果 validate.Match (inp).Success 然后
...
结束 如果


使用此代码



 公共 功能 ValidatePhone(sPhone  As  字符串作为 布尔 
Dim sReg 作为 System.Text.RegularExpressions.Regex( 961(71 | 72 | 76 | 79 | 3)\d {6 }
如果 sReg.IsMatch(sPhone)那么
返回 True
其他
返回 错误
结束 如果
结束 功能


i want a regular expression to validate this format of pnone number any help

961_(71 or 72 or 76 or 79 or 3)_and 6 digits number [0-9]

example: 96171648262,9613635241

thanks,

解决方案

Try:

961(71|72|76|79|3)\d{6}





"how could i use it in vb.net to validate a string"

Dim validate As New Regex("961(71|72|76|79|3)\d{6}")
Dim inp As String = "96171648262"
If validate.Match(inp).Success Then
    ...
End If


use this code

Public  Function ValidatePhone(sPhone As String) As Boolean
    Dim sReg As New System.Text.RegularExpressions.Regex("961(71|72|76|79|3)\d{6}")
    If sReg.IsMatch(sPhone) Then
        Return True
    Else
        Return False
    End If
End Function


这篇关于正则表达式以验证电话号码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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