Created
August 9, 2021 10:04
-
-
Save leodevbro/1ba044bea8aebdf4bb8aada433db175d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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