mirror of
https://github.com/natelandau/shell-scripting-templates.git
synced 2025-11-11 22:43:47 -05:00
Add options for nocasematch
This commit is contained in:
@@ -115,6 +115,11 @@ _isEmail_() {
|
||||
# _isEmail_ "somename+test@gmail.com"
|
||||
|
||||
[[ $# == 0 ]] && fatal "Missing required argument to ${FUNCNAME[0]}"
|
||||
|
||||
#shellcheck disable=SC2064
|
||||
trap "$(shopt -p nocasematch)" RETURN # reset nocasematch when function exits
|
||||
shopt -s nocasematch # Use case-insensitive regex
|
||||
|
||||
local _emailRegex
|
||||
_emailRegex="^[a-z0-9!#\$%&'*+/=?^_\`{|}~-]+(\.[a-z0-9!#$%&'*+/=?^_\`{|}~-]+)*@([a-z0-9]([a-z0-9-]*[a-z0-9])?\.)+[a-z0-9]([a-z0-9-]*[a-z0-9])?\$"
|
||||
[[ ${1} =~ ${_emailRegex} ]] && return 0 || return 1
|
||||
|
||||
Reference in New Issue
Block a user