Skip to content

Instantly share code, notes, and snippets.

@krivaten
Last active September 20, 2015 18:17
Show Gist options
  • Save krivaten/9473846 to your computer and use it in GitHub Desktop.
Save krivaten/9473846 to your computer and use it in GitHub Desktop.
A set of useful regular expressions
let regUrl = /^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/;
let regEmail = /^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})$/;
let regAlphaNumeric = /^[a-z0-9_-]{6,18}$/;
let reqNumeric = /^\d+$/;
let regAlpha = /^[a-zA-Z ]*$/;
// to test a value
if(regUrl.test('foo')) {
return true;
} else {
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment