更新时间:2023-02-21 13:32:23
尝试改用-match。例如,
Try using -match instead. E.g.,
$minSize = "20Gb" $regex = "^([0-9]{1,20})(b|kb|mb|gb|tb)$" $minSize -match $regex #Automatic $Matches variable created $size=[int64]$Matches[1] $unit=$Matches[2]
将正则表达式选项传递给PowerShell [regex]类型
将正则表达式修饰符选项传递给RegExp对象