Skip to content

Instantly share code, notes, and snippets.

@ekam230
Created September 27, 2019 04:46
Show Gist options
  • Save ekam230/9d8e83040e772e6feec0594ff0c5ed2a to your computer and use it in GitHub Desktop.
Save ekam230/9d8e83040e772e6feec0594ff0c5ed2a to your computer and use it in GitHub Desktop.
/* ------------------------------------------------------------------------ */
var regexes = {
num: /^\d+$/,
ports: /^\d+(-\d+)?(:\d+)?$/,
phone: /^[\d\*#\(),\-+wpdt]+$/,
'int': /^$0(x[\da-f]+|[0-7]+)|[1-9]\d+/i,
WPSPin: /^\d{8}$/,
pin: /^\d{4,8}$/,
hex: /^[\da-f]+$/i,
bound: /^\[(\d+)-(\d+)\]$/,
id: /^[a-z_]\w+$/i,
MAC: /^[\da-f]{2}([:\-]?[\da-f]{2}){5}$/i,
ascii: /^[\x20-\x7E]+$/,
login: /^[\w+\()\-_=]*$/,
password: /^[\x21-\x7E]*$/,
prinable: /^[\x20-\x7E]+$/,
time: /^([01]\d|2[0-3])(:[0-5]\d){2}$/,
date: /^([0-2]\d|3[01])\/(0[1-9]|1[0-2])\/(19[7-9]\d|20\d\d)$/,
IP: /^((0x?)?[\da-f]{1,3}\.){1,3}(0x?)?[\da-f]{1,8}$/i,
domain: /^[\w\-]*(\.[\w\-]+)*$/i,
URL: /^https?:\/\/([\w\.\-]+(:[\w\.\-]+)?@)?([a-z][\w\-]+(\.[\w\-]+)*|(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])(\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])){3})(:[\d]{1,5})?(\/([\w\-_@\.+!,]|(\%[\da-f]{2}))+)*\/?(\?([\w$\-_@\.&+!*\(\),=]|\%[\da-z]{2})*)?$/i,
folder: /^(\/[\s\w\-\.\_\+\(\)\`\'\"]+)*\/?$/i,
atcmd: /^AT[\x20-\x7F]*$/i,
net_ip: /^(\d{1,3}\.){1,3}[\d]{1,8}(\/\d{1,2})?$/i
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment