如何分割字符串内容转换成PowerShell中的字符串数组? [英] How to split a string content into an array of strings in Powershell?

查看:1136
本文介绍了如何分割字符串内容转换成PowerShell中的字符串数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有了电子邮件由分号分隔字符串

  $地址=foo@bar.com; boo@bar.com; zoo@bar.com
 

我怎么能分裂成字符串数组,这将导致该为:

  [字符串[]] $收件人=foo@bar.com,boo@bar.com,zoo@bar.com
 

解决方案

由于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 "; "

这篇关于如何分割字符串内容转换成PowerShell中的字符串数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆