From a8d8d2c515148e1ccc411ac4f3b3f039d748af6e Mon Sep 17 00:00:00 2001 From: Jonatan Schlag Date: Fri, 18 Aug 2017 13:45:18 +0200 Subject: [PATCH] util: add normalize function This function remove all non alpha numerical characters from a string and substitute this characters with one - So HELLO%%/$&/)%$%(&&HH becomes hello-hh Signed-off-by: Jonatan Schlag Signed-off-by: Michael Tremer --- src/functions/functions.util | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/functions/functions.util b/src/functions/functions.util index f096fbb7..dff0b907 100644 --- a/src/functions/functions.util +++ b/src/functions/functions.util @@ -850,3 +850,9 @@ copy() { return ${EXIT_ERROR} fi } + +normalize() { + local string="$@" + + tr -sc [:alnum:] "-" < <(printf "%s" "${string,,}") +} -- 2.47.3