Functions/Common/StringManipulation.ps1
function Clear-Substring { param ( [Parameter(Mandatory=$True)] [string] $string, [Parameter(Mandatory=$True)] [string] $substring, [string] $position ) if($position -eq "front") { $result = $string -ireplace ("^" + [regex]::Escape($substring)), "" } elseif($position -eq "back") { $result = $string -ireplace ([regex]::Escape($substring) + "$"), "" } else { $result = $string -ireplace [regex]::Escape($substring), "" } return $result } |