Adding brackets to variable
Hi,
Stupid question but didn't find answer yet: how can I add brackets to my variable,
$VariableWithoutBrackets = "1.0"
$VariableWithBrackets = '('$VariableWithoutBrackets')'
So that $VariableWithoutBrackets = 1.0 and $VariableWithBrackets = (1.0)
?
Please advise.
September 14th, 2015 6:30am
Clarification - what do you mean by "brackets"? You've posted an example with parentheses.
September 14th, 2015 8:03am
$VariableWithBrackets ="($VariableWithoutBrackets)"
OR
$VariableWithBrackets ='('+$VariableWithoutBrackets+')'
...and those are parenthesis ;)
September 14th, 2015 8:23am
Try:
$var2 = "("+$var1+")"
wizend
September 14th, 2015 8:34am
Your method will work - with ' as well - but there is a more efficient way of doing this.
Removing the + operators and the inside " will expand the variable and create the new string.
$var2 = "($var1)"
September 14th, 2015 8:56am
September 14th, 2015 10:33am
Yep.
Add the $() sub-expression operator to the list of working suggestions.
September 14th, 2015 12:21pm