Thanks Kiron! The solution with the -Contains operator gives me the correct
number of matched records. However the -Match operator solutions are
resulting in a greater number of matched records. Ì've not yet taken the time
to check out the reason.
Thanks for the help!
"Kiron" wrote:
Quote:
> Here are two ways, three including v2:
>
> # v1 and v2: using the -Contains operator
> $refVal = ipcsv RefVal.csv | % {$_.RefVal} | sort
> ipcsv RefValContent.csv | ? {$refVal -contains $_.RefValC}
>
> # v1: using the -Match operator and creating a regex pattern by joining
> # the array through string expansion and the Output Field Separator '$OFS'
> $refVal = ipcsv RefVal.csv | % {$_.RefVal} | sort
> $pat = &{$ofs = '|'; "$refVal"}
> ipcsv RefValContent.csv | ? {$_.RefValC -match $pat}
>
> # v2: using the -Match operator and creating a regex pattern by joining
> # the array through the -Join operator
> $refVal = ipcsv RefVal.csv | % {$_.RefVal} | sort
> ipcsv RefValContent.csv | ? {$_.RefValC -match ($refVal -join '|')}
>
> --
> Kiron
>