Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Join a string with inconsistent spaces

$
0
0

Hi guys,

I'm getting content from text file using Get-Content, I'm currently stuck, I want to turn the output into csv

Here is one line of my content that I need to join it with semicolon.

Thank you

cls
$string = "12REGA     8    672.00       84.00        38%      0      0.00        0.00         0%      8    672.00       84.00        32%"

$myString = ""

$string.split(" ") | ForEach {
    if ($_.Trim().Length -gt 0) {
        $myString =  $myString + ";" + $_

    }
}

Write-Host $myString 


Codernater


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>