Monday, September 9, 2013

Powershell Strings


$a = "This", "Is", "a", "cat"

# Operator join

# This Is a cat
$a -join ' '

# ThisIsacat
-join $a

# using conversion to [string] (and optionally use the separator $ofs)

# This Is a cat
[string]$a

# This-Is-a-cat
$ofs = '-' # ! after that all casts work in this way until $ofs changes !
[string]$a

No comments: