Removing line break powershell

后端 未结 3 916
礼貌的吻别
礼貌的吻别 2020-12-17 22:47

I am having an issue with a line break in my data. The array was made with an out-string followed by -split. If you want to see that part of the script let me know.

3条回答
  •  悲&欢浪女
    2020-12-17 23:39

    Well how about applying mjolinor's code at the $item level, e.g.:

    foreach ($item in $array) {
      $item -replace '^|$','_'
    }
    

    Although I expect the same result you are already getting, there are newlines embedded in your string.

    I'm not able to setup the same condition in $array myself, maybe you could post that code.

    Does this work?:

    foreach ($item in $array) {
      $item.Trim() -replace '^|$','_'
    }
    

提交回复
热议问题