So, using $_ -match \w covers me when the lines contain letters and/or numbers, which works in my particular case, but I assume there is a proper way to exclude empty lines?
Also, ($_).trim() doesn't seem to work, so I am having to do something to$_ , like $_ -replace "" (which I am hoping does nothing?), before trim actually works. So, what is the proper way to trim the object in the pipeline? I am guessing turn it into a string somehow?
Or is there a better way of doing all this altogether?
My goal is basically paste some input into ISE, split it into a multi line object, remove the empty lines, and trim the remaining lines.
Just need to double-check and try and figure out why {$_.Trim() } wouldn't work for me initially, so I had to use {($_ -replace "") .Trim() } just to have the .Trim() option available at all. It just wasn't working for $_.trim(). Also, the trimming wasn't getting rid of the empty lines, and in this example it does.
But it works for the example given.
rookie_b
ASKER
Never mind, can no longer replicate my original problem with $_.trim() not working. And this solution is much more elegant and efficient.
Just need to double-check and try and figure out why {$_.Trim() } wouldn't work for me initially, so I had to use {($_ -replace "") .Trim() } just to have the .Trim() option available at all. It just wasn't working for $_.trim(). Also, the trimming wasn't getting rid of the empty lines, and in this example it does.
But it works for the example given.