Skip to content

Instantly share code, notes, and snippets.

@chetanppatil
Created April 30, 2018 05:50
Show Gist options
  • Save chetanppatil/550209597e4613e75385396ddfdf2f06 to your computer and use it in GitHub Desktop.
Save chetanppatil/550209597e4613e75385396ddfdf2f06 to your computer and use it in GitHub Desktop.
Most commonly used regex, ES6
const phoneRegx = RegExp(/^[0]?[789]\d{9}$/)
const emailRegx = RegExp( /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/)
let phoneNumber = '9999999999'
let email = '[email protected]'
console.log('PHONE REGX:= ', phoneRegx.test(phoneNumber));
console.log('EMAIL REGX:= ', emailRegx.test(email));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment