我有一个名为
请问有人可以查看我的switch语句并看看为什么我在第6行出错。这就是switch语句正在通过的“case”。
tabLength
的函数,它应该返回一个字符串。这是为了在文本文档中进行格式化。请问有人可以查看我的switch语句并看看为什么我在第6行出错。这就是switch语句正在通过的“case”。
Function tabLength ( $line ) {
$lineLength = $line.Length
switch -regex ( $lineLength ) {
"[1-4]" { return "`t`t`t" }
"[5-15]" { return "`t`t" }
"[16-24]" { return "`t" }
default { return "`t" }
}
}
错误信息:
Invalid regular expression pattern: [5-15].
At C:\Users\name\desktop\nslookup.ps1:52 char:11
+ "[5-15]" <<<< { return "" }
+ CategoryInfo : InvalidOperation: ([5-15]:String) [], RuntimeException
+ FullyQualifiedErrorId : InvalidRegularExpression
只有通过[5-15]
发送的值才会出现这种情况。