Powershell Tip #117: Remove whitespaces from a string By powershellgu | September 10, 2016 0 Comment 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 ''