Forum Discussion
rmerritt
Jan 15, 2026Tin Contributor
extract a string from this @{Name=WEBHOST001-OI3w}
Hi All I just want to be able to get the value WEBHOST001-OI3w from @{Name=WEBHOST001-OI3w} the variable storing it is called $vcentername
server_gov
Nov 19, 2026Copper Contributor
I am a fan of regular expressions and in this instance you could use the following
$reg_replace = [string]”{0}” -f “^.+=|}$”
$vcentrename = $vcentrename -replace $reg_replace
how does this work
match group 1
- ^ - anchor start of string
- . - match any single non space character
- + - repeat matching any single non space character as required
- = - match literal character =
logic or
- | - match everything before and after
match group 2
- } - match literal character }
- $ - anchor end of string
replace
- regular expression replace the match with no value
outcome $vcentrename
- original - @{Name=WEBHOST001-OI3w}
- replace - WEBHOST001-OI3w