Last active
September 20, 2015 18:17
-
-
Save krivaten/9473846 to your computer and use it in GitHub Desktop.
A set of useful regular expressions
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
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