Sanitize
str_sanitise¶
Strip surrounding quotes, trailing ':' or '=' separators, and leading/trailing whitespace from a string. Accepts input as an argument or via stdin. Note: '%%:' and '%%=' strip from the first delimiter onwards — do not use on values that legitimately contain ':' or '=' (e.g. URLs).
Example¶
str_sanitise '" Bytes: "' # => Bytes
printf '%s' '"key": ' | str_sanitise # => key
Arguments¶
- $1 (string): Optional: the string to sanitise (reads stdin if omitted)
Exit codes¶
- 0: Always
Output on stdout¶
- Sanitised string
str_sanitize¶
Alias for str_sanitise.