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 jonatan.schlag@ipfire.org --- src/functions/functions.util | 10 ++++++++++ 1 file changed, 10 insertions(+)
diff --git a/src/functions/functions.util b/src/functions/functions.util index 24e3e66..8df0d86 100644 --- a/src/functions/functions.util +++ b/src/functions/functions.util @@ -845,3 +845,13 @@ copy() { return ${EXIT_ERROR} fi } + + +normalize() { + assert [ $# -eq 1 ] + + local string="${1}" + + string="${string,,}" + tr -sc [:alnum:] "-" < <(printf "%s" "${string}") +}