Functions/Get-StringWithWhitespaceReplaced.ps1
<#
.SYNOPSIS This function returns a string, which is the result of replacing all the whitespace characters in the input string with a given string. .DESCRIPTION This function returns a string, which is the result of replacing all the whitespace characters in the input string with a given string. If the original string contains successive whitespace characters like "`r`n", they will only be replaced by one string. The default replacement string is a space. #> function Get-StringWithWhitespaceReplaced { [CmdletBinding()] [OutputType([String])] param ( [Parameter(Mandatory=$true)] [ValidateNotNull()] [String]$string, [Parameter(Mandatory=$false)] [ValidateNotNull()] [String]$replacedBy = " " ) return $string -replace "\s+", $replacedBy } |