powershell - Powershell使用split只返回第n个元素

标签 powershell parsing

我怎样才能从这个简单的拆分中仅返回第二个数组元素:

$test="This,Home"
$test -split ","

返回值:
This
Home

我如何只返回“家”?

最佳答案

只需从列表中获取第二个元素(索引为1)

$test="This,Home" 
($test -split ",")[1]

关于powershell - Powershell使用split只返回第n个元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42670288/

相关文章:

PowerShell 脚本返回意外输出(随机数)

powershell - 我正在尝试使用不知道目标文件名的PowerShell来下载文件?

powershell - SSL 证书警告破坏 IE 自动化

powershell - runas.exe 和 Start-Process -Credential 的区别

php - 如何评估在 PHP 中作为字符串传递的公式?

php - 解析 Json 对象 PHP

parsing - Python3 - 为编译器创建扫描器并在测试时出错

python - python中的数据库连接字符串解析

在 Go 中解析 YAML : map in list

visual-studio - 通过Nuget Manager控制台在Visual Studio中打开文件