Reputation: 1546
In Windows command line, I got the output like this:
{D1AB12B0-B9B5-43A0-98E1-584D790524FE} Kaspersky for Windows
I am looking for a solution to split the above string into variables using }
as delimiter.
Any help is appreciated.
Thank you.
Huy
Upvotes: 1
Views: 233
Reputation: 32
Use .split()
or -split
with the desired delimiter. It makes an array out of those splitted parts, which you can than use by index and save it into a variable:
$string = '{D1AB12B0-B9B5-43A0-98E1-584D790524FE} Kaspersky for Windows'
$GUID = $string.split('}')[0].substring(1)
$ProductName= $string.split('}')[1].trim()
In my code .substring()
and .trim()
is just used for formatting purpose.
Upvotes: 1