【发布时间】:2017-05-22 04:46:41
【问题描述】:
运行此脚本时出现此错误:
使用“1”参数调用“匹配”的异常:“值不能 无效的。参数名称:input" at V:\compiler\shitter2.ps1:3 char:1 + $tables = $regex.matches((GC v:\compiler\test.txt -raw)).groups.value + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : ArgumentNullException
这是脚本代码:
$Path = 'V:\compiler\po.htm'
[regex]$regex = "(?s)<TABLE ID=.*?</TABLE>"
$tables = $regex.matches((GC v:\compiler\test.txt -raw)).groups.value
ForEach($String in $tables){
$table = $string.split("`n")
$CurTable = @()
$CurTableName = ([regex]'TABLE ID="
([^"]*)"').matches($table[0]).groups[1].value
$CurTable += ($table[1] -replace "</B></TH><TH><B>",",") -replace "</?
(TR|TH|B)>"
$CurTable += $table[2..($table.count-2)]|ForEach{$_ -replace "</TD>
<TD>","," -replace "</?T(D|R)>"}
$CurTable | convertfrom-csv | export-csv "$CurTableName.csv" -notype
}
【问题讨论】:
-
错误消息暗示
GC v:\compiler\test.txt -raw正在产生空值。如果我使用虚拟文件名尝试您的示例,我会收到相同的消息,前面是一条错误消息,指出该文件不存在。你的文件路径正确吗?你的文件内容是什么?这是完整的错误信息吗?
标签: powershell