Or simply replace it with a character that's illegal in a channel name, for example: $replace($chan,$(#,),$chr(44))