Header Ads

US Phone Number With Optional Extension Regular Expression

Are you looking for validation expression for US phone number with optional extension.

Here it is:

^\d{3}-\d{3}-\d{4}(-\d{2,4})?$

It accepts the following

123-456-7890-9999
123-456-7890-999
123-456-7890-99

Minimum Extension length is 2 and Maximum is 4 and it is optional.

We can change the minimum and maximum lengths by simply replacing the values of MIN and MAX.

^\d{3}-\d{3}-\d{4}(-\d{MIN,MAX})?$

2 comments:

  1. This is what commonly happens to the newbies in the business industry who do not know how to effectively market their product or service or service.cashmio

    ReplyDelete

Powered by Blogger.