The Replace
function can be used to remove characters from a string. If you just echo the return value without assigning it back to the variable, the original string will remain unchanged:
>>> str = "Grilled Cheese"
>>> WScript.Echo Replace(str, " ", "")
GrilledCheese
>>> WScript.Echo str
Grilled Cheese
Another option would be the Split
and Join
functions:
>>> str = "Grilled Cheese"
>>> WScript.Echo Join(Split(str, " "), "")
GrilledCheese
>>> WScript.Echo str
Grilled Cheese
Split
will also allow you to echo just particular tokens from the original string:
>>> str = "Grilled Cheese"
>>> WScript.Echo Split(str, " ")(1)
Cheese