-
-
Save adriancmiranda/aaffce74830a2217a49f42274323554a to your computer and use it in GitHub Desktop.
Revisions
-
guessi revised this gist
Oct 3, 2020 . 1 changed file with 11 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -10,7 +10,7 @@ # please be noted that, it is not design to detect mailbox deliverability # regex="^(([A-Za-z0-9]+((\.|\-|\_|\+)?[A-Za-z0-9]?)*[A-Za-z0-9]+)|[A-Za-z0-9]+)@(([A-Za-z0-9]+)+((\.|\-|\_)?([A-Za-z0-9]+)+)*)+\.([A-Za-z]{2,})+$" valid_inputs=( "[email protected]" @@ -64,15 +64,20 @@ valid_inputs=( "[email protected]" "[email protected]" "[email protected]" "valid..2020@example.com" "valid__2020@example.com" "valid+-2020@example.com" ) invalid_inputs=( "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "inv [email protected]" "invalid@exa mple.com" "[email protected]" @@ -134,9 +139,11 @@ a simple email address validator in bash online validator: http://emailregex.com/ RFC Standards for email address - https://tools.ietf.org/html/rfc821 - https://tools.ietf.org/html/rfc5322 - https://tools.ietf.org/html/rfc6854 - https://tools.ietf.org/html/rfc5321 - https://tools.ietf.org/html/rfc5322#section-3.4 References: - http://emailregex.com/email-validation-summary/ -
guessi revised this gist
Sep 29, 2020 . 1 changed file with 60 additions and 24 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,11 +1,31 @@ #!/usr/bin/env bash # # RFC standard of the email address could be found in rfc5322, rfc6854, etc. # # however, it is hard to escape all the special characters in the bash # so, in this script, it will only check for the address syntax only # having some valid/invalid inputs to test its result # # please be noted that, it is not design to detect mailbox deliverability # regex="^([A-Za-z0-9]+((\.|\-|\_|\+)?[A-Za-z0-9]?)*[A-Za-z0-9]?)@(([A-Za-z0-9]+)+((\.|\-|\_)?([A-Za-z0-9]+)+)*)+\.([A-Za-z]{2,})+$" valid_inputs=( "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "valid+1@ex_ample.com" "[email protected]" "[email protected]" "[email protected]" "valid+01@ex_ample.com" "[email protected]" "[email protected]" "[email protected]" @@ -20,18 +40,33 @@ valid_inputs=( "[email protected]" "valid@e-x_ample.com" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" ) invalid_inputs=( @@ -40,18 +75,7 @@ invalid_inputs=( "[email protected]" "inv [email protected]" "invalid@exa mple.com" "[email protected]" "invalid@_" "invalid@com" "[email protected]" @@ -61,19 +85,26 @@ invalid_inputs=( "[email protected]_ample.com" "[email protected]" "invalid@example._" "[email protected]" "invalid@example.+" "[email protected]" "[email protected]" "[email protected]" "invalid@example." "[email protected]." "[email protected]" "[email protected]" "invalid@_.com" "[email protected]" "invalid@com" "[email protected]" "invalid@+com" "invalid@-com" "invalid@_com" "invalid@." "invalid@_" "invalid@-" "[email protected]" "@" ".@." "-@-" @@ -89,8 +120,6 @@ invalid_inputs=( "[email protected]" ) function validator { if [[ $1 =~ ${regex} ]]; then printf "* %-48s \e[1;32m[pass]\e[m\n" "${1}" @@ -100,10 +129,17 @@ function validator { } cat <<-EOF a simple email address validator in bash online validator: http://emailregex.com/ RFC Standards for email address - https://tools.ietf.org/html/rfc5322 - https://tools.ietf.org/html/rfc6854 - https://tools.ietf.org/html/rfc5321 References: - http://emailregex.com/email-validation-summary/ EOF echo -
guessi revised this gist
Sep 29, 2020 . 1 changed file with 22 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -20,8 +20,18 @@ valid_inputs=( "[email protected]" "valid@e-x_ample.com" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" ) invalid_inputs=( @@ -40,11 +50,10 @@ invalid_inputs=( "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "invalid@_" "invalid@com" "[email protected]" "invalid@example._com" "invalid@e-x._ample.com" @@ -58,20 +67,29 @@ invalid_inputs=( "invalid@example." "[email protected]." "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "invalid@com" "@" ".@." "-@-" "_@_" "+@+" "a.@.." "@com" "@example.com" "[email protected]" "[email protected]" "invalid@_123.com" "[email protected]" "[email protected]" ) regex="^([A-Za-z]+((\.|\-|\_)?[A-Za-z0-9])*\+?((\.|\-|\_)?[A-Za-z]+[A-Za-z0-9]*)*)@(([A-Za-z0-9]+)+((\.|\-|\_)?([A-Za-z0-9]+)+)*)+\.([A-Za-z]{2,})+$" function validator { if [[ $1 =~ ${regex} ]]; then -
guessi revised this gist
Apr 10, 2020 . 1 changed file with 18 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,10 @@ #!/usr/bin/env bash valid_inputs=( "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" @@ -17,6 +21,7 @@ valid_inputs=( "valid@e-x_ample.com" "[email protected]" "[email protected]" "[email protected]" ) invalid_inputs=( @@ -52,9 +57,21 @@ invalid_inputs=( "[email protected]" "invalid@example." "[email protected]." "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "invalid@com" "@com" "@example.com" "[email protected]" "[email protected]" "invalid@_123.com" "[email protected]" ) regex="^([A-Za-z]+[A-Za-z0-9]*\+?((\.|\-|\_)?[A-Za-z]+[A-Za-z0-9]*)*)@(([A-Za-z0-9]+)+((\.|\-|\_)?([A-Za-z0-9]+)+)*)+\.([A-Za-z]{2,})+$" function validator { if [[ $1 =~ ${regex} ]]; then -
guessi revised this gist
Aug 4, 2019 . 1 changed file with 75 additions and 63 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,76 +1,88 @@ #!/usr/bin/env bash valid_inputs=( "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "valid@e-x_ample.com" "[email protected]" "[email protected]" ) invalid_inputs=( "[email protected]" "[email protected]" "[email protected]" "inv [email protected]" "invalid@exa mple.com" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "invalid@example._com" "invalid@e-x._ample.com" "[email protected]_ample.com" "[email protected]_ample.com" "[email protected]" "invalid@example._" "[email protected]" "[email protected]" "[email protected]" "invalid@example." "[email protected]." ) regex="^([A-Za-z]+[A-Za-z0-9]*((\.|\-|\_)?[A-Za-z]+[A-Za-z0-9]*){1,})@(([A-Za-z]+[A-Za-z0-9]*)+((\.|\-|\_)?([A-Za-z]+[A-Za-z0-9]*)+){1,})+\.([A-Za-z]{2,})+$" function validator { if [[ $1 =~ ${regex} ]]; then printf "* %-48s \e[1;32m[pass]\e[m\n" "${1}" else printf "* %-48s \e[1;31m[fail]\e[m\n" "${1}" fi } cat <<-EOF a simple email validator in shell online validator: http://emailregex.com/ RFC: http://emailregex.com/email-validation-summary/ EOF echo echo "### expected result: valid" echo for input in "${valid_inputs[@]}"; do validator "${input}" done echo echo "### expected result: invalid" echo for input in "${invalid_inputs[@]}"; do validator "${input}" done -
guessi created this gist
Dec 16, 2016 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,76 @@ #!/bin/bash validator() { printf "* %-48s" "$1" echo "$1" | egrep --quiet "^([A-Za-z]+[A-Za-z0-9]*((\.|\-|\_)?[A-Za-z]+[A-Za-z0-9]*){1,})@(([A-Za-z]+[A-Za-z0-9]*)+((\.|\-|\_)?([A-Za-z]+[A-Za-z0-9]*)+){1,})+\.([A-Za-z]{2,})+" [ $? -eq 0 ] && printf "\e[1;32m[pass]\e[m" || printf "\e[1;31m[fail]\e[m" echo } echo echo "a simple email validator in shell" echo echo "online validator: http://emailregex.com/" echo "RFC: http://emailregex.com/email-validation-summary/" echo echo echo "### expected result: valid" echo validator "[email protected]" validator "[email protected]" validator "[email protected]" validator "[email protected]" validator "[email protected]" validator "[email protected]" validator "[email protected]" validator "[email protected]" validator "[email protected]" validator "[email protected]" validator "[email protected]" validator "[email protected]" validator "[email protected]" validator "valid@e-x_ample.com" validator "[email protected]" validator "[email protected]" echo echo "### expected result: invalid" echo validator "[email protected]" validator "[email protected]" validator "[email protected]" validator "inv [email protected]" validator "invalid@exa mple.com" validator "[email protected]" validator "[email protected]" validator "[email protected]" validator "[email protected]" validator "[email protected]" validator "[email protected]" validator "[email protected]" validator "[email protected]" validator "[email protected]" validator "[email protected]" validator "[email protected]" validator "[email protected]" validator "[email protected]" validator "[email protected]" validator "[email protected]" validator "[email protected]" validator "invalid@example._com" validator "invalid@e-x._ample.com" validator "[email protected]_ample.com" validator "[email protected]_ample.com" validator "[email protected]" validator "invalid@example._" validator "[email protected]" validator "[email protected]" validator "[email protected]" validator "[email protected]" echo echo "### END" echo