powershell -split('') 指定一个新行 [英] powershell -split('') specify a new line

查看:50
本文介绍了powershell -split('') 指定一个新行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Get-Content $user| Foreach-Object{
   $user = $_.Split('=')
   New-Variable -Name $user[0] -Value $user[1]}

我正在尝试编写一个脚本并将其拆分为一个数组,根据每个新行拆分文件

Im trying to work on a script and have it split a text file into an array, splitting the file based on each new line

我应该如何将="符号更改为

What should I change the "=" sign to

推荐答案

这取决于文本文件的确切编码,但 [Environment]::NewLine 通常可以解决问题.

It depends on the exact encoding of the textfile, but [Environment]::NewLine usually does the trick.

"This is `r`na string.".Split([Environment]::NewLine)

输出:

这是

一个字符串.

这篇关于powershell -split('') 指定一个新行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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