Skip to content

Instantly share code, notes, and snippets.

@ianaya89
Created December 16, 2014 18:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ianaya89/86c9ac484942784ff8cb to your computer and use it in GitHub Desktop.
Save ianaya89/86c9ac484942784ff8cb to your computer and use it in GitHub Desktop.
var Patterns = {
INT: /[0-9 -()+]+$/,
FLOAT: /[-+]?([0-9]*.[0-9]+|[0-9]+)/,
EMAIL: /^[A-Z0-9._%+-]+@[A-Z0-9.-]+.[A-Z]{2,4}$/,
IP: /bd{1,3}.d{1,3}.d{1,3}.d{1,3}b/,
CREDIT_CARD: /^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35d{3})d{11})$/,
USER_NAME: /^[a-z0-9_-]{3,16}$/,
PASSWORD: /^[a-z0-9_-]{6,18}$/,
PASSWORD_STRENGTH: /((?=.*d)(?=.*[a-z])(?=.*[A-Z]).{8,15})/gm,
PHONE: /[0-9-()+]{3,20}/,
DATE: /(d{1,2}/d{1,2}/d{4})/gm,
URL: /^(https?://)?([da-z.-]+).([a-z.]{2,6})([/w .-]*)*/?$/,
VOWELS: /^[aeiou]/,
WHITE_TABS: /^[ t]+|[ t]+$/,
WHITE_BREAKS: /[ trn]/,
DOMAIN: /(.*?)[^w{3}.]([a-zA-Z0-9]([a-zA-Z0-9-]{0,65}[a-zA-Z0-9])?.)+[a-zA-Z]{2,6}/igm,
IMAGE: /([^s]+(?=.(jpg|gif|png)).2)/gm,
HTML: /^< ([a-z]+)([^<]+)*(?:>(.*)< /1>|s+/>)$/,
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment