Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

^(?:(+|00)d{1,3}[-s.])?(()?d{3,10}())?(?:[-s.)]d{2,7}([-s.]d{2,5})?([-s.]d{2})?)?$

// regular expression in Javascript looking for matching phones 
let phones = [
    "+1-234-567-8901",
    "+41-234-567-89-01",
    "+33-234 5678901",
    "+1 (234) 568 9901",
    "+30.234.567.8901",
    "001 234 56 78901",
    "001 234 567 8901",
    "+1 6134138417",
    "800-123-4567",
    "(800) 123 4567",
    "(212)867-5509"
]

const regex = new RegExp(/^(?:(+|00)d{1,3}[-s.])?(()?d{3,10}())?(?:[-s.)]d{2,7}([-s.]d{2,5})?([-s.]d{2})?)?$/, 'i');

phones.forEach(phones => console.log(phones, regex.test(phones)));
Source by gist.github.com #
 
PREVIOUS NEXT
Tagged:
ADD COMMENT
Topic
Name
6+2 =