Reputation: 231
How can I construct regx to validate phone number? That is:
I have tried this pattern:
^[04,050]\\d{8,13}
Can any body help me?
Upvotes: 1
Views: 813
Reputation: 336078
Let's break it down (hoping I understand correctly):
^ # Start of string
(?: # Match one of the following:
04\d{6,11} # Either an 8-13 digit number starting with 04
| # or
050\d{5,10} # an 8-13 digit number starting with 050
| # or
4[0-25-9]\d{6} # an 8 digit number starting with 4 but not 43 or 44
| # or
9\d{7} # an 8 digit number starting with 9
) # End of alternation
$ # End of string
Upvotes: 3