且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何分割字符串内容转换成PowerShell中的字符串数组?

更新时间:2022-10-18 10:50:49

由于PowerShell的2,简单: $收件人= $地址-split;

I have a string that has emails separated by semi-colon

$address = "foo@bar.com; boo@bar.com; zoo@bar.com"

How can I split this into an array of strings that would result as:

[string[]]$recipients = "foo@bar.com", "boo@bar.com", "zoo@bar.com"

As of powershell 2, simple: $recipients = $addresses -split "; "