Docs:
returns $value without invalid characters for a Hostname
if $allowMultipleLabels is not nothing, then it also allows dots between labels
Execution:
/system script run stripInvalidHostNameCharactersFromString
:put [$stripInvalidHostNameCharactersFromString value=("a host name")]
ahostname
:put [$stripInvalidHostNameCharactersFromString value=("a host name.domain name" ) allowMultipleLabels="yes"]
ahostname.domainname
Any comments on the source: https://gist.github.com/jpluimers/de92cf8dcf3ccdbaef2d3083749c4c89