Splitting a string into separate variables

davetherave picture davetherave · Jun 3, 2015 · Viewed 309.7k times · Source

I have a string, which I have split using the code $CreateDT.Split(" "). I now want to manipulate two separate strings in different ways. How can I separate these into two variables?

Answer

mjolinor picture mjolinor · Jun 3, 2015

Like this?

$string = 'FirstPart SecondPart'
$a,$b = $string.split(' ')
$a
$b