regex - Regular Expression to Match North American Phone Numbers Not Working -


^(\(\d{3}\)|^\d{3}[.-]?)?\d{3}[.-]?\d{4}$ 

the above regular expression have created matching north-american phone number , without parenthesis in code. not working, don't seem find issue.

(180)-555-5555 --> not matching 180-555-5555 --> matching 

some 1 me understand why not matching? '\(\d{3}\)' used capture parenthesis.

you may try this,

^(\(\d{3}\)|\d{3})?([.-]?)\d{3}\2\d{4}$ 

demo


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

spring cloud - How to configure SpringCloud Eureka instance to point to https on non standard port -

javascript - Bootstrap Popover: iOS Safari strange behaviour -