Hi guys,
I am trying to read in text file and regular expression using windows powershell script. Here is my sample script as below:
$reg = "#########" Get-Content .\aa.txt |Select-String -Pattern $reg -AllMatches | ForEach-Object { $_.Matches } | ForEach-Object { $_.Value }
The file name is aa.txt:
12.36 -65.32 "Alice Smith" "" "" -55
36.85 -24.39 "Bob Smith" "" "" -74
In display output as above code:
12.36
-65.32
Alice Smith
-55
36.85
-24.39
Bob Smith
-74
But i want to display output like this:
12.36,-65.32,Alice Smith,,,-55,
36.85,-24.39,Bob Smith,,,-74,
I figured ....| ForEach-Object {($_ -replace "\s+",",")} and not working.
Any Idea?
Thanks