US Phone Number With Optional Extension Regular Expression
Are you looking for validation expression for US phone number with optional extension.
Here it is:
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.
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})?$
No comments: