As a workaround you can do that by adding extra variable and using datasource capabilities. Example for InfluxDB and Flux:
import "strings"
import "array"
array.from(rows: [{result : strings.replaceAll(v: "${var_name:text}", t: " ", u: "")}])
var_name_2 doesn’t have spaces: