Skip to content

Commit

Permalink
Add function to remove dots and slashes (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
evertramos authored Jan 27, 2022
1 parent 18d3606 commit e54a282
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions string/string-remove-dot-slash-from-string.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#-----------------------------------------------------------------------
#
# Basescript function
#
# The basescript functions were designed to work as abstract function,
# so it could be used in many different contexts executing specific job
# always remembering Unix concept DOTADIW - "Do One Thing And Do It Well"
#
# Developed by
# Evert Ramos <[email protected]>
#
# Copyright Evert Ramos
#
#-----------------------------------------------------------------------
#
# Be careful when editing this file, it is part of a bigger script!
#
# Basescript - https://github.com/evertramos/basescript
#
#-----------------------------------------------------------------------

#-----------------------------------------------------------------------
# This function has one main objective:
# 1. Remove dot (.) and slash (/) from a string
#
# You must/might inform the parameters below:
# 1. String that will be analized
# 2. [optional] (default: )
#
#-----------------------------------------------------------------------
string_remove_dot_slash_from_string()
{
local LOCAL_STRING

LOCAL_STRING=${1:-null}

[[ $LOCAL_STRING == "" || $LOCAL_STRING == null ]] && echoerror "You must inform the required argument(s) to the function: '${FUNCNAME[0]}'"

[[ "$DEBUG" == true ]] && echo "Removing dots (.) and slashes (/) from '$LOCAL_STRING'"

STRING_REMOVE_DOT_SLASH_FROM_STRING_RESPONSE=$(echo $LOCAL_STRING | tr -d ' ./' | tr '[:upper:]' '[:lower:]' | tr -d '[:cntrl:]')

return 0
}

0 comments on commit e54a282

Please sign in to comment.