initial Commit
This commit is contained in:
26
Private/Normalize-ConfigurationDataSeparator.ps1
Normal file
26
Private/Normalize-ConfigurationDataSeparator.ps1
Normal file
@@ -0,0 +1,26 @@
|
||||
function Normalize-ConfigurationDataSeparator {
|
||||
[CmdletBinding()]
|
||||
Param(
|
||||
[AllowNull()]
|
||||
[string]
|
||||
$Value,
|
||||
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string]
|
||||
$Separator
|
||||
)
|
||||
|
||||
if($null -eq $Value){
|
||||
return ""
|
||||
}
|
||||
|
||||
if([string]::IsNullOrEmpty($Separator)){
|
||||
return $Value
|
||||
}
|
||||
|
||||
$EscapedSeparator = [regex]::Escape($Separator)
|
||||
$Normalized = [regex]::Replace($Value, "($EscapedSeparator){2,}", $Separator)
|
||||
$Normalized = $Normalized.Trim()
|
||||
$Normalized = [regex]::Replace($Normalized, "^$EscapedSeparator|$EscapedSeparator$", "")
|
||||
return $Normalized
|
||||
}
|
||||
Reference in New Issue
Block a user