Skip to content

Instantly share code, notes, and snippets.

@wizard04wsu
Last active May 22, 2020 19:11
Show Gist options
  • Save wizard04wsu/369bc03c6023822f9ca86506cd337bec to your computer and use it in GitHub Desktop.
Save wizard04wsu/369bc03c6023822f9ca86506cd337bec to your computer and use it in GitHub Desktop.
Regular expressions
Phone numbers:
https://gist.github.com/wizard04wsu/11458504
Email validation (complex):
^((?:[!#$%&'*+\-/0-9=?A-Z^_`a-z{|}~]+(?:\.[!#$%&'*+\-/0-9=?A-Z^_`a-z{|}~]+)*)|(?:"(?:(?:(?:(?:[\t ]*\r?\n)?[\t ]+)?(?:[!#$%&'()*+,\-./0-9:;<=>?@A-Z[\]^_`a-z{|}~]|\\[\t !-~])+)+(?:(?:[\t ]*\r?\n)?[\t ]+)?|(?:(?:[\t ]*\r?\n)?[\t ]+))"))@(\d+(?:\.\d+){3}|\[(?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4}){5}:(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|\d+(?:\.\d+){3})|(?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4})*)?::(?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4})*)?)\]|(?:[0-9A-Za-z](?:[0-9A-Za-z-]{0,61}[0-9A-Za-z])?)(?:\.[0-9A-Za-z](?:[0-9A-Za-z-]{0,61}[0-9A-Za-z])?)*)$
Email validation (simpler):
^((?:[!#$%&'*+\-/0-9=?A-Z^_`a-z{|}~]+(?:\.[!#$%&'*+\-/0-9=?A-Z^_`a-z{|}~]+)*)|(?:"(?:[!#$%&'()*+,\-./0-9:;<=>?@A-Z[\]^_`a-z{|}~\t ]|\\[\t !-~])+"))@([A-Za-z-][0-9A-Za-z-]*(?:\.[A-Za-z-][0-9A-Za-z-]*)*|\d+(?:\.\d+){3}|\[[0-9A-Fa-f:.]+\])$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment