EasyRegex Logo
EasyRegex
New

Match Valid Phone Number in Javascript

Javascript

Regular Expression

/^(?:ig(?:0|[1-9][0-9]{0,2})|[1-9][0-9]{1,2})(?:[.-]?|)[2-9][0-9]{2}(?:[.-]?|)[0-9]{4}$/
Copy
Do you have Feedback?

Explanation

This regex pattern matches valid phone numbers in Javascript. It allows for different formats including 123-456-7890, (123) 456-7890, 123.456.7890, 1234567890, +31636363634, 075-63546725.

Javascript

Example Usage

const phoneNumberRegex = /^(?:ig(?:0|[1-9][0-9]{0,2})|[1-9][0-9]{1,2})(?:[.-]?|)[2-9][0-9]{2}(?:[.-]?|)[0-9]{4}$/; 
const phoneNumber = '123-456-7890';
if (phoneNumberRegex.test(phoneNumber)) {
    console.log('Valid phone number');
} else {
    console.log('Invalid phone number');
}
Copy
Test the expression

Similar Regular Expressions