Javascript Regular Expressions Match phone number

Description

Javascript Regular Expressions Match phone number



let ssn = "123-23-1234";
let pattern = /^\d{3}-\d{2}-\d{4}$/;
if (ssn.match(pattern))
  console.log("OK");
else//from   ww  w  .j a  v a  2 s . c o m
  console.log("Not OK");



PreviousNext

Related