I get this error when running this script:
Exception calling "Matches" with "1" argument(s): "Value cannot be null. Parameter name: 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
Here is the script code:
$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 -rawis producing null. If I try your example with a dummy file name I get the same message preceded by an error message saying that the file does not exist. Have you got your file path correct? What is the contents of your file? Is this the full error message. - Dave Sexton