Since Compare-Object cannot take wildcards, how would I compare two arrays for contents that make not be exactly the same in length or contents, but similar enough for a wildcard set or a regex to catch them.
Example:
$form = "First Name","Last Name","Address","Phone","Nickname","Fax Number"
$data = "First Name ","Last Name","Street Address","Phone number","",Fax"
Can I compare the arrays without doing a bunch of if statements and operators? A switch would probably be more elegant, but I just so want to be able to do this on one line simlar to this:
Compare-Object ("*$form*) ("*$data*")
Instead of like this:
for($x=0;$x -lt $form.Count;$x++)
{
[string]$xx = $x
if($form[$x] -like "*$data[$x]*" -or $data[$x] -like "*form[$x]*" -and $data[$x] -ne $null -and $form[$x] -ne $null)
{
$form[$x]
$data[$x]
}
elseif($form[$x] -eq $null -and $data[$x] -eq $null)
{
"Form index $xx and Data index $xx are null"
}
elseif($form[$x] -eq $null)
{
"Form index $xx is null"
}
elseif($data[$x] -eq $null)
{
"Data index $xx is null"
}
else
{
"Data index $xx and Form index $xx are not even close to the same"
}
}