us phone number regex javascript code example

Example 1: javascript regex french phone number

function regexPhoneNumber(str) {
	const regexPhoneNumber = /^((\+)33|0)[1-9](\d{2}){4}$/; 
  
	if (str.match(regexPhoneNumber)) {
		return true;
	} else {
		return false;
	}
}

let phoneNumber = "+33777777777";
console.log(regexPhoneNumber(phoneNumber));

Example 2: regex to check the phone number javascript

//To check that the phone number is of 10 digits
let regex=/^[0-9]{10}$/;

Example 3: USA phone number validator angular

^(\([0-9]{3}\)|[0-9]{3}-)[0-9]{3}-[0-9]{4}$