Over a million developers have joined DZone.
Silver Partner

Regular Expression For Validate Phone Numbers.

· Java Zone

The Java Zone is presented by Hazelcast.  Learn more about Hazelcast on Azure and the best practices for seamless deployment of Hazelcast on Azure Virtual Machines.


function checkPhone(str) 
{
var phone2 = /^(\+\d)*\s*(\(\d{3}\)\s*)*\d{3}(-{0,1}|\s{0,1})\d{2}(-{0,1}|\s{0,1})\d{2}$/; 
if (str.match(phone2)) {
   return true;
 } else {
 return false;
 }
}


Phone format 
phone:
339-4248
339-42-48
339 42 48
339 4248
3394248
(095) #phone#
(095)#phone#
+7 (095) #phone#
+7 (095)#phone#
+7(095) #phone#
+7(095)#phone#

The Java Zone is presented by Hazelcast.  Learn more about Hazelcast on Azure and the best practices for seamless deployment of Hazelcast on Azure Virtual Machines.

Topics:
java

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}