Skip to content

Instantly share code, notes, and snippets.

@leodevbro
Created August 9, 2021 10:04
Show Gist options
  • Save leodevbro/1ba044bea8aebdf4bb8aada433db175d to your computer and use it in GitHub Desktop.
Save leodevbro/1ba044bea8aebdf4bb8aada433db175d to your computer and use it in GitHub Desktop.
const myPhone = "412341006541651";
const myRegex = new RegExp(`^5[0-9]*`);
const myArray = myPhone.match(myRegex);
if (myArray) {
console.log("this number starts with 5:", myArray.length > 0);
} else {
console.log("this number starts with 5:", false);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment