Browse Source

Get-NameRegex: feature Exclude, test scriptblock for recurse

temp1
pcnick 3 years ago
parent
commit
c06c9d51fd
  1. 15
      NameRegex.ps1

15
NameRegex.ps1

@ -2,6 +2,7 @@
param(
$Str,
$Regex,
[switch] $Exclude,
[switch] $End
)
# Regex 可輸入複數個
@ -25,6 +26,20 @@
} else { $Result.Remove("Anchor") }
$Result
}
if ($Exclude) {
$InterSB = {
if ($_["Target"] -match $_["Regex"]) {
$Result = @{
$key = $Matches[$key]
# 將錨定字串中的特殊字元轉換為一般字串
Anchor = $Matches[0] -replace "([\[\]\(\)])", '\$1'
}
$LR = $_["Target"] -split $Result["Anchor"]
$Result.Add("L", $LR[0])
$Result.Add("R", $LR[1])
}
}
}
}
}

Loading…
Cancel
Save