How to split a string by space using PowerShell? PowerShell provides an easy way to do it using "split" method in PowerShell. The split method accepts any delimiter; it can be space, dash, comma or other characters as long as it has a pattern on the string. The split method will literally split the string and the output is displayed on a separate line or separated via a line feed. Example: $string = "This is my test string" $split_string_array = $string -split " " $split_string_array Output will be: This is my test string If there is a need to remove the spaces but combine the string in one line, PowerShell also provides the "join" method which basically combine or joins the string in one line. Example: $string = "This is my test string" $split_string_array = $string -split " " $join_string_array = $split_string_array -Join "" Write-Host ...
Make the world a better place by sharing knowledge, ideas and anything that you can give that comes from the heart.