简体   繁体   中英

Phone Number Regular Expression

Basically I am 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}\)?[*]*$

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM