Click here to Skip to main content
15,884,177 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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,
Posted

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




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

VB
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
 
Share this answer
 
v2
Comments
[no name] 4-Sep-13 4:39am    
how could i use it in vb.net to validate a string
OriginalGriff 4-Sep-13 5:00am    
Answer updated
[no name] 4-Sep-13 5:18am    
thanks it works
OriginalGriff 4-Sep-13 5:24am    
You're welcome!
[no name] 4-Sep-13 5:30am    
it fail on this number 96130000560.. this number has 7 digits after the (3) it should have 6 only
use this code

VB
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
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900