This repository has been archived on 2024-03-04. You can view files and clone it, but cannot push or open issues or pull requests.
linux/.config/bash/module/parse.sh

21 lines
457 B
Bash
Raw Normal View History

2023-10-30 03:49:10 +03:00
# parse data and output simplified format.
# usage: parse_simplify <STRING>
parse_simplify()
{
echo "${*}" | \
sed -e "s/ /_/g" \
2023-11-08 02:37:05 +03:00
-e "s/[^[:alnum:]_-]//g" \
-e "s/_\+/_/g" -e "s/-\+/-/g" \
-e "s/_-/_/g" -e "s/-_/_/g" \
2023-10-30 03:49:10 +03:00
-e "s/_\+/_/g" \
-e "s/^_//" -e "s/_$//"
}
# parse data keeping only alphanumeric characters.
# usage: parse_alnum <STRING>
parse_alnum()
{
echo "${*}" | \
sed -e "s/[^[:alnum:]]//g"
}