Skip to content

Instantly share code, notes, and snippets.

@BrainFeeder
Last active March 22, 2017 08:40
Show Gist options
  • Save BrainFeeder/0013d317b19150fc9f8c6ad1fc3113cf to your computer and use it in GitHub Desktop.
Save BrainFeeder/0013d317b19150fc9f8c6ad1fc3113cf to your computer and use it in GitHub Desktop.
String validation regex (used by cPanel)
var match_validators = {
fullemailaddress: eval("/^([a-zA-Z0-9_'+*$%^&!.-])+[@+](([a-zA-Z0-9-])+.)+([a-zA-Z0-9:]{2,4})+$/"),
emailcharplus: eval("/^([a-zA-Z0-9_'+.-])/"),
emailaddress: /^[^\@]\@[^\.]\./,
emailchars: /^[a-z0-9\_\-\@\.]+$/,
email_localpart_chars: /^\w[\w-.+%]*/,
email_localpart_chars_cap: /^[A-Za-z0-9\_\-\.]+$/,
atsign: /\@/,
notestsign: /\@/,
hostname: /^((\*\.|[a-zA-Z0-9])([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,6}$/,
fqdn_domain: /^((\*\.|[a-zA-Z0-9])([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.){2}[a-zA-Z]{2,6}$/,
fullipaddr: /^(\d{1,3}\.){3}\d{1,3}$/,
is_ipcidr_or_host: /^[a-z0-9\.\-\/]+$/,
ipcidr: /^\d+\.\d+\.\d+\.\d+\/?\d*$/,
host: /^[\w\.\-]+$/,
wildhost: /^[\*\w\.\-]+$/,
wildhostsql: /^[\%\w\.\-]+$/,
unlimitedornum: /^[0-9]*$|^unlimited$/,
numeric: /^[0-9]+$/,
decimal_numeric: /^[-+]?[0-9]+(\.[0-9]+)?$/,
decimal_numeric_unlimited: /^[-+]?[0-9]+(\.[0-9]+)?$|^unlimited$/,
alphanum: /^[a-z0-9\_\-]+$/i,
"start_www.": /^www[.]/i,
jpg_gif_png_jpeg: /\.(gif|jpg|png|jpeg)$/,
html: /\.(html)$/,
spaces_dots_ats_fwdslashes_hyphens: /[\s\.\@\/\-]/,
spaces_dots_ats_fwdslashes: /[\s\.\@\/]+/,
two_dots: /[^\.]\.[^\.]\.[^\.]/,
spaces_ats_fwdslashes: /[\s\@\/]+/,
start_end_dashes: /(?:^[-]|[-]$)/,
start_end_space: /(?:^[\s]|[\s]$)/,
slashes_dots: /[\.\/\\]/,
noascii0_255: /[\0\255]/,
spaces: /\s+/,
forwardslash: /\//,
dot: /\./,
empty: /^$/,
start_end_dots: /(^[.]|[.]$)/,
start_dot: /^\./,
underscore: /\_/,
protocol: /^\S+[:][/][/]/,
only_spaces: /^\s+$/,
ssl_chars: /^[\-\w\!\+\@\~\:]+$/,
whole_nums: /^\d+$/,
"1_9only": /^[1-9]$/
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment