Powershell Tip #117: Remove whitespaces from a string By powershellgu | September 10, 2016 2 Comments Tip: You can remove multiple whitespaces from a string. PowerShell $test = 'one two three' # Solution 1 $test -replace '\s+', '' # Solution 2 (slower) $test.Split('',[System.StringSplitOptions]::RemoveEmptyEntries) -join '' 1234567 $test = 'one two three' # Solution 1$test -replace '\s+', '' # Solution 2 (slower)$test.Split('',[System.StringSplitOptions]::RemoveEmptyEntries) -join ''
Pingback: Powershell Tip #118: Test if path is a file or a folder using Test-Path cmdlet | Powershell Guru
Pingback: Powershell Tip #116: Remove empty elements from an array | Powershell Guru