Phone Number Regular Expression
Basically I 开发者_如何学Pythonam looking for a regular expression for phone numbers.
Inputs can be:
009133434343443434
+92333232323232
0223323232
0345*
021*
What I have tried
^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$
Maximum number of characters in my field can be 20 and least number of fields can be 3 but by the above reg ex i am unable to find appropriate results.
*
can only come in end
+
can only come at the start of string.try to understand regex from this site : http://www.wellho.net/regex/java.html
check out the regex library here for addresses and phone numbers: http://regexlib.com/DisplayPatterns.aspx?cattabindex=6&categoryId=7
(refresh that last site to get phone number patterns at the beginning.)
I have worked for it and now its working fine for me thanks to All for such a fast response specially saher
^[+ .]?[01]?[01]?\(?[2-9]\d{1,15}\)?[*]*$
精彩评论